Hosts no longer need QuickSearchOpenSearchClient or a copy of this qbit's diagnostics. The new public api package holds: - QuickSearchStatus, an immutable snapshot: overall state, cluster reachability, per-table index counts, backlog, last sync, last error and checkedAt; - QuickSearchStatusService.get(), bounded and cached for five seconds, built on the existing diagnostics; - QuickSearchApi, with the app name and home href, so hosts link to the Quick Search home instead of duplicating it. The same data is served as UI API extension operation GET /qqq/v1/qbit/quick-search/status (getQuickSearchStatus), gated by the admin permission. The fragment is committed and checked by a contract test. The core baseline becomes 4.1.0-RC.6. Closes #50 (architecture review QRun-IO/qqq#1150, finding F10). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
87 lines
3.8 KiB
Java
87 lines
3.8 KiB
Java
/*
|
|
* QQQ - Low-code Application Framework for Engineers.
|
|
* Copyright (C) 2021-2026. Kingsrook, LLC
|
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
|
* contact@kingsrook.com
|
|
* https://github.com/Kingsrook/
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package com.kingsrook.qbits.quicksearch.api;
|
|
|
|
|
|
import java.time.Instant;
|
|
import java.util.List;
|
|
import com.kingsrook.qqq.middleware.javalin.schemabuilder.ToSchema;
|
|
import com.kingsrook.qqq.openapi.model.Schema;
|
|
|
|
|
|
/*******************************************************************************
|
|
** Immutable administrative snapshot. Null measurements are unknown, never zero.
|
|
** Counts come from persisted diagnostics; countsCheckedAt identifies their age.
|
|
*******************************************************************************/
|
|
public record QuickSearchStatus(State state, Boolean clusterReachable, String clusterHealth, Integer nodes, Integer activeShards, Integer unassignedShards,
|
|
Boolean indexingPaused, List<IndexRow> indexes, Integer pending, Integer exhausted, Boolean backlogTruncated,
|
|
Boolean tablesTruncated, Instant lastSuccessfulSync, String lastError, Instant checkedAt, String homeHref) implements ToSchema
|
|
{
|
|
/*******************************************************************************
|
|
** Published wire schema for the same immutable value used by Java hosts.
|
|
*******************************************************************************/
|
|
@Override
|
|
public Schema toSchema()
|
|
{
|
|
return (new QuickSearchStatusSpec().defineComponentSchemas().get("QuickSearchStatusV1"));
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
** Protect the snapshot from mutations by callers.
|
|
*******************************************************************************/
|
|
public QuickSearchStatus
|
|
{
|
|
indexes = List.copyOf(indexes);
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
** Overall availability; DEGRADED also covers incomplete measurements.
|
|
*******************************************************************************/
|
|
public enum State
|
|
{
|
|
OK, DEGRADED, DOWN, DISABLED
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
** A persisted index row with counts from the latest saved validation, when
|
|
** available. Otherwise documentCount is the last indexing run's count and
|
|
** sourceCount/countsCheckedAt are unknown. Sync time is a successful watermark.
|
|
*******************************************************************************/
|
|
public record IndexRow(String tableName, Boolean enabled, String status, Long documentCount, Long sourceCount, Instant countsCheckedAt,
|
|
Instant lastSuccessfulSync, String lastError, Integer realTimeErrorCount) implements ToSchema
|
|
{
|
|
/*******************************************************************************
|
|
** Published per-table schema.
|
|
*******************************************************************************/
|
|
@Override
|
|
public Schema toSchema()
|
|
{
|
|
return (new QuickSearchStatusSpec().defineComponentSchemas().get("QuickSearchIndexStatusV1"));
|
|
}
|
|
}
|
|
}
|