From 8d4ef982d0f057c27b743a9488b75e1dce3d2d39 Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Thu, 22 Feb 2024 19:37:59 +0100 Subject: [PATCH] Clean up docs --- code/common/service-discovery/readme.md | 38 ++++++++++++++-------- code/services-core/query-service/readme.md | 13 +++----- settings.gradle | 2 -- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/code/common/service-discovery/readme.md b/code/common/service-discovery/readme.md index 3436db6a..764a271e 100644 --- a/code/common/service-discovery/readme.md +++ b/code/common/service-discovery/readme.md @@ -28,11 +28,22 @@ services: ```java // Register one or more services -registry.registerService(ApiSchema.GRPC, - ServiceId.Test, - nodeId, - instanceUUID, //must be unique to the runtime - "127.0.0.1"); // bind-address +serviceRegistry.registerService( + ServiceKey.forRest(serviceId, nodeId), + instanceUuid, // unique + externalAddress); // bind-address + +// Non-partitioned GRPC service +serviceRegistry.registerService( + ServiceKey.forServiceDescriptor(descriptor, ServicePartition.any()), + instanceUuid, + externalAddress); + +// Partitioned GRPC service +serviceRegistry.registerService( + ServiceKey.forServiceDescriptor(descriptor, ServicePartition.partition(5)), + instanceUuid, + externalAddress); // (+ any other services) ``` @@ -40,9 +51,7 @@ Then, the caller must announce their instance. Before this is done, the service is not discoverable. ```java -registry.announceInstance(ServiceId.Test, - nodeId, - instanceUUID); +registry.announceInstance(instanceUUID); ``` All of this is done automatically by the `Service` base class @@ -51,16 +60,19 @@ in the [service](../service/) module. To discover a service, the caller can query the registry: ```java -Set> endpoints = registry.getEndpoints(ApiSchema.GRPC, ServiceId.Test, nodeId); - -for (var endpoint : endpoints) { - System.out.println(endpoint.getHost() + ":" + endpoint.getPort()); -} +Set endpoints = registry.getEndpoints(serviceKey); ``` It's also possible to subscribe to changes in the registry, so that the caller can be notified when a service comes or goes, with `registry.registerMonitor()`. +However the `GrpcChannelPoolFactory` is a more convenient way to access the services, +it will let the caller create a pool of channels to the services, and manage their +lifecycle, listen to lifecycle notifications and so on. + +The ChannelPools exist in two flavors, one for partitioned services, and one for non-partitioned services. + + ### Central Classes * [ServiceRegistryIf](src/main/java/nu/marginalia/service/discovery/ServiceRegistryIf.java) diff --git a/code/services-core/query-service/readme.md b/code/services-core/query-service/readme.md index 1c9d2b66..d2ba1961 100644 --- a/code/services-core/query-service/readme.md +++ b/code/services-core/query-service/readme.md @@ -13,13 +13,10 @@ specific stuff. This mode of operations is available through a `barebones` inst The web interface also offers a JSON API for machine-based queries. -## Main Classes +## Central Classes -* [QueryService](src/main/java/nu/marginalia/query/QueryService.java) - The REST service implementation -* [QueryGRPCService](src/main/java/nu/marginalia/query/QueryGRPCService.java) - The GRPC service implementation +This module is almost entirely boilerplate, except the [QueryBasicInterface](src/main/java/nu/marginalia/query/QueryBasicInterface.java) +class, which offers a REST API for querying the index. -## See Also - -* [api/query-api](../../api/query-api) -* [features-qs/query-parser](../../features-qs/query-parser) -* [features-index/index-query](../../features-index/index-query) \ No newline at end of file +Much of the guts of the query service are in the [query-service](../../functions/search-query) +module; which offers query parsing and an interface to the index service partitions. diff --git a/settings.gradle b/settings.gradle index ac6f98d0..b6f2f9c0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -65,8 +65,6 @@ include 'code:features-crawl:crawl-blocklist' include 'code:features-crawl:link-parser' include 'code:features-crawl:content-type' - -include 'code:api:index-api' include 'code:api:process-mqapi' include 'code:api:executor-api'