From e860011fe65ce98757859be139798c2147c28948 Mon Sep 17 00:00:00 2001 From: "R.I.Pienaar" Date: Wed, 28 Dec 2022 14:13:27 +0200 Subject: [PATCH] add response type hints to micro responses This adds type hints in line with those used by JetStream API to micro responses. The goal is to be able to attach JSON schema (and others) to these for validation, documentation, discovery of design and more. These schemas will be surfaced in "nats schema" command as well. Signed-off-by: R.I.Pienaar --- adr/ADR-32.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/adr/ADR-32.md b/adr/ADR-32.md index 2f897516..55ac66ef 100644 --- a/adr/ADR-32.md +++ b/adr/ADR-32.md @@ -94,6 +94,10 @@ Services should respond to: All discovery and status responses contain the following fields: ```typescript + /** + * An identifier of the message type for example io.nats.micro.v1.stats + */ + type: string, /** * The kind of the service reporting the status */ @@ -115,6 +119,7 @@ Returns a JSON having the following structure: ```typescript { + type: string, name: string, id: string, version: string, @@ -137,12 +142,15 @@ All the fields above map 1-1 to the metadata provided when the service was created. Note that `subject` is the subject that the service is listening for requests on. +The type for this is `io.nats.micro.v1.info_response`. + ### PING Returns the following schema (the standard response fields) ```typescript { + type: string, name: string, id: string, version: string, @@ -152,6 +160,8 @@ Returns the following schema (the standard response fields) The intention of `PING` is for clients to calculate RTT to a service and discover services. +The type for this is `io.nats.micro.v1.ping_response`. + ### SCHEMA Returns a JSON having the following structure. Note that the `schema` struct is @@ -159,6 +169,7 @@ only returned if the `schema` was specified when created. ```typescript { + type: string, name: string, id: string, version: string, @@ -178,6 +189,8 @@ only returned if the `schema` was specified when created. } ``` +The type for this is `io.nats.micro.v1.schema_response`. + ### STATS ```typescript @@ -216,6 +229,8 @@ only returned if the `schema` was specified when created. } ``` +The type for this is `io.nats.micro.v1.stats_response`. + ## Error Handling Services may communicate request errors back to the client as they see fit, but