Skip to content
Snippets Groups Projects
Commit a26ab13e authored by Lyuben Penkovski's avatar Lyuben Penkovski
Browse files

Add service version to healtcheck responses

parent 145ede9a
Branches
No related tags found
No related merge requests found
Showing with 413 additions and 111 deletions
......@@ -66,7 +66,7 @@ func main() {
)
{
cacheSvc = cache.New(redis, events, logger)
healthSvc = health.New()
healthSvc = health.New(Version)
}
// create endpoints
......
......@@ -20,7 +20,7 @@ var _ = Service("health", func() {
Method("Liveness", func() {
Payload(Empty)
Result(Empty)
Result(HealthResponse)
HTTP(func() {
GET("/liveness")
Response(StatusOK)
......@@ -29,7 +29,7 @@ var _ = Service("health", func() {
Method("Readiness", func() {
Payload(Empty)
Result(Empty)
Result(HealthResponse)
HTTP(func() {
GET("/readiness")
Response(StatusOK)
......
......@@ -18,3 +18,10 @@ var CacheSetRequest = Type("CacheSetRequest", func() {
Field(5, "ttl", Int)
Required("data", "key")
})
var HealthResponse = Type("HealthResponse", func() {
Field(1, "service", String, "Service name.")
Field(2, "status", String, "Status message.")
Field(3, "version", String, "Service runtime version.")
Required("service", "status", "version")
})
......@@ -28,13 +28,21 @@ func NewClient(liveness, readiness goa.Endpoint) *Client {
}
// Liveness calls the "Liveness" endpoint of the "health" service.
func (c *Client) Liveness(ctx context.Context) (err error) {
_, err = c.LivenessEndpoint(ctx, nil)
return
func (c *Client) Liveness(ctx context.Context) (res *HealthResponse, err error) {
var ires any
ires, err = c.LivenessEndpoint(ctx, nil)
if err != nil {
return
}
return ires.(*HealthResponse), nil
}
// Readiness calls the "Readiness" endpoint of the "health" service.
func (c *Client) Readiness(ctx context.Context) (err error) {
_, err = c.ReadinessEndpoint(ctx, nil)
return
func (c *Client) Readiness(ctx context.Context) (res *HealthResponse, err error) {
var ires any
ires, err = c.ReadinessEndpoint(ctx, nil)
if err != nil {
return
}
return ires.(*HealthResponse), nil
}
......@@ -37,7 +37,7 @@ func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) {
// "Liveness" of service "health".
func NewLivenessEndpoint(s Service) goa.Endpoint {
return func(ctx context.Context, req any) (any, error) {
return nil, s.Liveness(ctx)
return s.Liveness(ctx)
}
}
......@@ -45,6 +45,6 @@ func NewLivenessEndpoint(s Service) goa.Endpoint {
// "Readiness" of service "health".
func NewReadinessEndpoint(s Service) goa.Endpoint {
return func(ctx context.Context, req any) (any, error) {
return nil, s.Readiness(ctx)
return s.Readiness(ctx)
}
}
......@@ -14,9 +14,9 @@ import (
// Health service provides health check endpoints.
type Service interface {
// Liveness implements Liveness.
Liveness(context.Context) (err error)
Liveness(context.Context) (res *HealthResponse, err error)
// Readiness implements Readiness.
Readiness(context.Context) (err error)
Readiness(context.Context) (res *HealthResponse, err error)
}
// ServiceName is the name of the service as defined in the design. This is the
......@@ -28,3 +28,13 @@ const ServiceName = "health"
// are the same values that are set in the endpoint request contexts under the
// MethodKey key.
var MethodNames = [2]string{"Liveness", "Readiness"}
// HealthResponse is the result type of the health service Liveness method.
type HealthResponse struct {
// Service name.
Service string
// Status message.
Status string
// Service runtime version.
Version string
}
......@@ -48,7 +48,7 @@ func BuildSetPayload(cacheSetBody string, cacheSetKey string, cacheSetNamespace
{
err = json.Unmarshal([]byte(cacheSetBody), &body)
if err != nil {
return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "\"Corporis omnis itaque earum quasi.\"")
return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "\"Dolorem et quam et illum.\"")
}
}
var key string
......@@ -99,7 +99,7 @@ func BuildSetExternalPayload(cacheSetExternalBody string, cacheSetExternalKey st
{
err = json.Unmarshal([]byte(cacheSetExternalBody), &body)
if err != nil {
return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "\"Enim vel.\"")
return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "\"Quis rerum velit sunt rerum dignissimos at.\"")
}
}
var key string
......
......@@ -23,15 +23,15 @@ import (
//
// command (subcommand1|subcommand2|...)
func UsageCommands() string {
return `health (liveness|readiness)
cache (get|set|set-external)
return `cache (get|set|set-external)
health (liveness|readiness)
`
}
// UsageExamples produces an example of a valid invocation of the CLI tool.
func UsageExamples() string {
return os.Args[0] + ` health liveness` + "\n" +
os.Args[0] + ` cache get --key "Sed consequatur rerum occaecati." --namespace "Veritatis exercitationem repudiandae eos." --scope "Sint dolorum occaecati."` + "\n" +
return os.Args[0] + ` cache get --key "Voluptatum modi tenetur tempore quia est ratione." --namespace "Corrupti sunt dolores." --scope "Repellat omnis id ex."` + "\n" +
os.Args[0] + ` health liveness` + "\n" +
""
}
......@@ -45,12 +45,6 @@ func ParseEndpoint(
restore bool,
) (goa.Endpoint, any, error) {
var (
healthFlags = flag.NewFlagSet("health", flag.ContinueOnError)
healthLivenessFlags = flag.NewFlagSet("liveness", flag.ExitOnError)
healthReadinessFlags = flag.NewFlagSet("readiness", flag.ExitOnError)
cacheFlags = flag.NewFlagSet("cache", flag.ContinueOnError)
cacheGetFlags = flag.NewFlagSet("get", flag.ExitOnError)
......@@ -71,16 +65,22 @@ func ParseEndpoint(
cacheSetExternalNamespaceFlag = cacheSetExternalFlags.String("namespace", "", "")
cacheSetExternalScopeFlag = cacheSetExternalFlags.String("scope", "", "")
cacheSetExternalTTLFlag = cacheSetExternalFlags.String("ttl", "", "")
)
healthFlags.Usage = healthUsage
healthLivenessFlags.Usage = healthLivenessUsage
healthReadinessFlags.Usage = healthReadinessUsage
healthFlags = flag.NewFlagSet("health", flag.ContinueOnError)
healthLivenessFlags = flag.NewFlagSet("liveness", flag.ExitOnError)
healthReadinessFlags = flag.NewFlagSet("readiness", flag.ExitOnError)
)
cacheFlags.Usage = cacheUsage
cacheGetFlags.Usage = cacheGetUsage
cacheSetFlags.Usage = cacheSetUsage
cacheSetExternalFlags.Usage = cacheSetExternalUsage
healthFlags.Usage = healthUsage
healthLivenessFlags.Usage = healthLivenessUsage
healthReadinessFlags.Usage = healthReadinessUsage
if err := flag.CommandLine.Parse(os.Args[1:]); err != nil {
return nil, nil, err
}
......@@ -96,10 +96,10 @@ func ParseEndpoint(
{
svcn = flag.Arg(0)
switch svcn {
case "health":
svcf = healthFlags
case "cache":
svcf = cacheFlags
case "health":
svcf = healthFlags
default:
return nil, nil, fmt.Errorf("unknown service %q", svcn)
}
......@@ -115,16 +115,6 @@ func ParseEndpoint(
{
epn = svcf.Arg(0)
switch svcn {
case "health":
switch epn {
case "liveness":
epf = healthLivenessFlags
case "readiness":
epf = healthReadinessFlags
}
case "cache":
switch epn {
case "get":
......@@ -138,6 +128,16 @@ func ParseEndpoint(
}
case "health":
switch epn {
case "liveness":
epf = healthLivenessFlags
case "readiness":
epf = healthReadinessFlags
}
}
}
if epf == nil {
......@@ -158,16 +158,6 @@ func ParseEndpoint(
)
{
switch svcn {
case "health":
c := healthc.NewClient(scheme, host, doer, enc, dec, restore)
switch epn {
case "liveness":
endpoint = c.Liveness()
data = nil
case "readiness":
endpoint = c.Readiness()
data = nil
}
case "cache":
c := cachec.NewClient(scheme, host, doer, enc, dec, restore)
switch epn {
......@@ -181,6 +171,16 @@ func ParseEndpoint(
endpoint = c.SetExternal()
data, err = cachec.BuildSetExternalPayload(*cacheSetExternalBodyFlag, *cacheSetExternalKeyFlag, *cacheSetExternalNamespaceFlag, *cacheSetExternalScopeFlag, *cacheSetExternalTTLFlag)
}
case "health":
c := healthc.NewClient(scheme, host, doer, enc, dec, restore)
switch epn {
case "liveness":
endpoint = c.Liveness()
data = nil
case "readiness":
endpoint = c.Readiness()
data = nil
}
}
}
if err != nil {
......@@ -190,40 +190,6 @@ func ParseEndpoint(
return endpoint, data, nil
}
// healthUsage displays the usage of the health command and its subcommands.
func healthUsage() {
fmt.Fprintf(os.Stderr, `Health service provides health check endpoints.
Usage:
%[1]s [globalflags] health COMMAND [flags]
COMMAND:
liveness: Liveness implements Liveness.
readiness: Readiness implements Readiness.
Additional help:
%[1]s health COMMAND --help
`, os.Args[0])
}
func healthLivenessUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] health liveness
Liveness implements Liveness.
Example:
%[1]s health liveness
`, os.Args[0])
}
func healthReadinessUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] health readiness
Readiness implements Readiness.
Example:
%[1]s health readiness
`, os.Args[0])
}
// cacheUsage displays the usage of the cache command and its subcommands.
func cacheUsage() {
fmt.Fprintf(os.Stderr, `Cache service allows storing and retrieving data from distributed cache.
......@@ -248,7 +214,7 @@ Get JSON value from the cache.
-scope STRING:
Example:
%[1]s cache get --key "Sed consequatur rerum occaecati." --namespace "Veritatis exercitationem repudiandae eos." --scope "Sint dolorum occaecati."
%[1]s cache get --key "Voluptatum modi tenetur tempore quia est ratione." --namespace "Corrupti sunt dolores." --scope "Repellat omnis id ex."
`, os.Args[0])
}
......@@ -263,7 +229,7 @@ Set a JSON value in the cache.
-ttl INT:
Example:
%[1]s cache set --body "Corporis omnis itaque earum quasi." --key "Et eligendi nihil optio natus assumenda." --namespace "Quasi perspiciatis." --scope "Accusantium animi non alias." --ttl 3495630911155968941
%[1]s cache set --body "Dolorem et quam et illum." --key "Esse inventore ullam placeat aut." --namespace "Omnis itaque." --scope "Quasi ut." --ttl 3100652887298323449
`, os.Args[0])
}
......@@ -278,6 +244,40 @@ Set an external JSON value in the cache and provide an event for the input.
-ttl INT:
Example:
%[1]s cache set-external --body "Enim vel." --key "Ut in." --namespace "Ab dolores distinctio quis." --scope "Optio aliquam error nam." --ttl 2227603043401673122
%[1]s cache set-external --body "Quis rerum velit sunt rerum dignissimos at." --key "Optio aliquam error nam." --namespace "Recusandae illo." --scope "Placeat veniam veritatis doloribus." --ttl 5137048679846705449
`, os.Args[0])
}
// healthUsage displays the usage of the health command and its subcommands.
func healthUsage() {
fmt.Fprintf(os.Stderr, `Health service provides health check endpoints.
Usage:
%[1]s [globalflags] health COMMAND [flags]
COMMAND:
liveness: Liveness implements Liveness.
readiness: Readiness implements Readiness.
Additional help:
%[1]s health COMMAND --help
`, os.Args[0])
}
func healthLivenessUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] health liveness
Liveness implements Liveness.
Example:
%[1]s health liveness
`, os.Args[0])
}
func healthReadinessUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] health readiness
Readiness implements Readiness.
Example:
%[1]s health readiness
`, os.Args[0])
}
......@@ -51,7 +51,20 @@ func DecodeLivenessResponse(decoder func(*http.Response) goahttp.Decoder, restor
}
switch resp.StatusCode {
case http.StatusOK:
return nil, nil
var (
body LivenessResponseBody
err error
)
err = decoder(resp).Decode(&body)
if err != nil {
return nil, goahttp.ErrDecodingError("health", "Liveness", err)
}
err = ValidateLivenessResponseBody(&body)
if err != nil {
return nil, goahttp.ErrValidationError("health", "Liveness", err)
}
res := NewLivenessHealthResponseOK(&body)
return res, nil
default:
body, _ := io.ReadAll(resp.Body)
return nil, goahttp.ErrInvalidResponse("health", "Liveness", resp.StatusCode, string(body))
......@@ -93,7 +106,20 @@ func DecodeReadinessResponse(decoder func(*http.Response) goahttp.Decoder, resto
}
switch resp.StatusCode {
case http.StatusOK:
return nil, nil
var (
body ReadinessResponseBody
err error
)
err = decoder(resp).Decode(&body)
if err != nil {
return nil, goahttp.ErrDecodingError("health", "Readiness", err)
}
err = ValidateReadinessResponseBody(&body)
if err != nil {
return nil, goahttp.ErrValidationError("health", "Readiness", err)
}
res := NewReadinessHealthResponseOK(&body)
return res, nil
default:
body, _ := io.ReadAll(resp.Body)
return nil, goahttp.ErrInvalidResponse("health", "Readiness", resp.StatusCode, string(body))
......
......@@ -6,3 +6,84 @@
// $ goa gen gitlab.eclipse.org/eclipse/xfsc/tsa/cache/design
package client
import (
health "gitlab.eclipse.org/eclipse/xfsc/tsa/cache/gen/health"
goa "goa.design/goa/v3/pkg"
)
// LivenessResponseBody is the type of the "health" service "Liveness" endpoint
// HTTP response body.
type LivenessResponseBody struct {
// Service name.
Service *string `form:"service,omitempty" json:"service,omitempty" xml:"service,omitempty"`
// Status message.
Status *string `form:"status,omitempty" json:"status,omitempty" xml:"status,omitempty"`
// Service runtime version.
Version *string `form:"version,omitempty" json:"version,omitempty" xml:"version,omitempty"`
}
// ReadinessResponseBody is the type of the "health" service "Readiness"
// endpoint HTTP response body.
type ReadinessResponseBody struct {
// Service name.
Service *string `form:"service,omitempty" json:"service,omitempty" xml:"service,omitempty"`
// Status message.
Status *string `form:"status,omitempty" json:"status,omitempty" xml:"status,omitempty"`
// Service runtime version.
Version *string `form:"version,omitempty" json:"version,omitempty" xml:"version,omitempty"`
}
// NewLivenessHealthResponseOK builds a "health" service "Liveness" endpoint
// result from a HTTP "OK" response.
func NewLivenessHealthResponseOK(body *LivenessResponseBody) *health.HealthResponse {
v := &health.HealthResponse{
Service: *body.Service,
Status: *body.Status,
Version: *body.Version,
}
return v
}
// NewReadinessHealthResponseOK builds a "health" service "Readiness" endpoint
// result from a HTTP "OK" response.
func NewReadinessHealthResponseOK(body *ReadinessResponseBody) *health.HealthResponse {
v := &health.HealthResponse{
Service: *body.Service,
Status: *body.Status,
Version: *body.Version,
}
return v
}
// ValidateLivenessResponseBody runs the validations defined on
// LivenessResponseBody
func ValidateLivenessResponseBody(body *LivenessResponseBody) (err error) {
if body.Service == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("service", "body"))
}
if body.Status == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("status", "body"))
}
if body.Version == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("version", "body"))
}
return
}
// ValidateReadinessResponseBody runs the validations defined on
// ReadinessResponseBody
func ValidateReadinessResponseBody(body *ReadinessResponseBody) (err error) {
if body.Service == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("service", "body"))
}
if body.Status == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("status", "body"))
}
if body.Version == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("version", "body"))
}
return
}
......@@ -11,6 +11,7 @@ import (
"context"
"net/http"
health "gitlab.eclipse.org/eclipse/xfsc/tsa/cache/gen/health"
goahttp "goa.design/goa/v3/http"
)
......@@ -18,8 +19,11 @@ import (
// health Liveness endpoint.
func EncodeLivenessResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error {
return func(ctx context.Context, w http.ResponseWriter, v any) error {
res, _ := v.(*health.HealthResponse)
enc := encoder(ctx, w)
body := NewLivenessResponseBody(res)
w.WriteHeader(http.StatusOK)
return nil
return enc.Encode(body)
}
}
......@@ -27,7 +31,10 @@ func EncodeLivenessResponse(encoder func(context.Context, http.ResponseWriter) g
// health Readiness endpoint.
func EncodeReadinessResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error {
return func(ctx context.Context, w http.ResponseWriter, v any) error {
res, _ := v.(*health.HealthResponse)
enc := encoder(ctx, w)
body := NewReadinessResponseBody(res)
w.WriteHeader(http.StatusOK)
return nil
return enc.Encode(body)
}
}
......@@ -6,3 +6,51 @@
// $ goa gen gitlab.eclipse.org/eclipse/xfsc/tsa/cache/design
package server
import (
health "gitlab.eclipse.org/eclipse/xfsc/tsa/cache/gen/health"
)
// LivenessResponseBody is the type of the "health" service "Liveness" endpoint
// HTTP response body.
type LivenessResponseBody struct {
// Service name.
Service string `form:"service" json:"service" xml:"service"`
// Status message.
Status string `form:"status" json:"status" xml:"status"`
// Service runtime version.
Version string `form:"version" json:"version" xml:"version"`
}
// ReadinessResponseBody is the type of the "health" service "Readiness"
// endpoint HTTP response body.
type ReadinessResponseBody struct {
// Service name.
Service string `form:"service" json:"service" xml:"service"`
// Status message.
Status string `form:"status" json:"status" xml:"status"`
// Service runtime version.
Version string `form:"version" json:"version" xml:"version"`
}
// NewLivenessResponseBody builds the HTTP response body from the result of the
// "Liveness" endpoint of the "health" service.
func NewLivenessResponseBody(res *health.HealthResponse) *LivenessResponseBody {
body := &LivenessResponseBody{
Service: res.Service,
Status: res.Status,
Version: res.Version,
}
return body
}
// NewReadinessResponseBody builds the HTTP response body from the result of
// the "Readiness" endpoint of the "health" service.
func NewReadinessResponseBody(res *health.HealthResponse) *ReadinessResponseBody {
body := &ReadinessResponseBody{
Service: res.Service,
Status: res.Status,
Version: res.Version,
}
return body
}
{"swagger":"2.0","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":""},"host":"localhost:8083","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get JSON value from the cache.","operationId":"cache#Get","produces":["application/json"],"parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":false,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":false,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","operationId":"cache#Set","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":false,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":false,"type":"string"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","required":false,"type":"integer"},{"name":"any","in":"body","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"201":{"description":"Created response."}},"schemes":["http"]}},"/v1/external/cache":{"post":{"tags":["cache"],"summary":"SetExternal cache","description":"Set an external JSON value in the cache and provide an event for the input.","operationId":"cache#SetExternal","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":false,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":false,"type":"string"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","required":false,"type":"integer"},{"name":"any","in":"body","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"200":{"description":"OK response."}},"schemes":["http"]}}}}
\ No newline at end of file
{"swagger":"2.0","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":""},"host":"localhost:8083","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/HealthLivenessResponseBody","required":["service","status","version"]}}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/HealthReadinessResponseBody","required":["service","status","version"]}}},"schemes":["http"]}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get JSON value from the cache.","operationId":"cache#Get","produces":["application/json"],"parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":false,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":false,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","operationId":"cache#Set","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":false,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":false,"type":"string"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","required":false,"type":"integer"},{"name":"any","in":"body","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"201":{"description":"Created response."}},"schemes":["http"]}},"/v1/external/cache":{"post":{"tags":["cache"],"summary":"SetExternal cache","description":"Set an external JSON value in the cache and provide an event for the input.","operationId":"cache#SetExternal","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":false,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":false,"type":"string"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","required":false,"type":"integer"},{"name":"any","in":"body","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"200":{"description":"OK response."}},"schemes":["http"]}}},"definitions":{"HealthLivenessResponseBody":{"title":"HealthLivenessResponseBody","type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Laborum reprehenderit rerum est et ut dolores."},"status":{"type":"string","description":"Status message.","example":"Consequatur porro qui est dolor a."},"version":{"type":"string","description":"Service runtime version.","example":"Ad dolor."}},"example":{"service":"Fugiat voluptatem vel et.","status":"Sint tempore est nam iusto.","version":"Ipsam quidem aut velit vitae est."},"required":["service","status","version"]},"HealthReadinessResponseBody":{"title":"HealthReadinessResponseBody","type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Repellat qui totam et recusandae."},"status":{"type":"string","description":"Status message.","example":"Dolores at qui aliquam ullam."},"version":{"type":"string","description":"Service runtime version.","example":"Omnis ex fugit corporis."}},"example":{"service":"Minima sed et.","status":"Veniam optio qui.","version":"Suscipit velit aliquid et."},"required":["service","status","version"]}}}
\ No newline at end of file
......@@ -22,6 +22,12 @@ paths:
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/HealthLivenessResponseBody'
required:
- service
- status
- version
schemes:
- http
/readiness:
......@@ -33,6 +39,12 @@ paths:
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/HealthReadinessResponseBody'
required:
- service
- status
- version
schemes:
- http
/v1/cache:
......@@ -145,3 +157,52 @@ paths:
description: OK response.
schemes:
- http
definitions:
HealthLivenessResponseBody:
title: HealthLivenessResponseBody
type: object
properties:
service:
type: string
description: Service name.
example: Laborum reprehenderit rerum est et ut dolores.
status:
type: string
description: Status message.
example: Consequatur porro qui est dolor a.
version:
type: string
description: Service runtime version.
example: Ad dolor.
example:
service: Fugiat voluptatem vel et.
status: Sint tempore est nam iusto.
version: Ipsam quidem aut velit vitae est.
required:
- service
- status
- version
HealthReadinessResponseBody:
title: HealthReadinessResponseBody
type: object
properties:
service:
type: string
description: Service name.
example: Repellat qui totam et recusandae.
status:
type: string
description: Status message.
example: Dolores at qui aliquam ullam.
version:
type: string
description: Service runtime version.
example: Omnis ex fugit corporis.
example:
service: Minima sed et.
status: Veniam optio qui.
version: Suscipit velit aliquid et.
required:
- service
- status
- version
{"openapi":"3.0.3","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":"1.0"},"servers":[{"url":"http://localhost:8083","description":"Cache Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}}}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get JSON value from the cache.","operationId":"cache#Get","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Delectus quaerat molestiae placeat nemo.","format":"binary"},"example":"Quia dolores rem."}}}}},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","operationId":"cache#Set","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","allowEmptyValue":true,"schema":{"type":"integer","description":"Cache entry TTL in seconds","example":60,"format":"int64"},"example":60}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"string","example":"Quis rerum velit sunt rerum dignissimos at.","format":"binary"},"example":"Est illum."}}},"responses":{"201":{"description":"Created response."}}}},"/v1/external/cache":{"post":{"tags":["cache"],"summary":"SetExternal cache","description":"Set an external JSON value in the cache and provide an event for the input.","operationId":"cache#SetExternal","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","allowEmptyValue":true,"schema":{"type":"integer","description":"Cache entry TTL in seconds","example":60,"format":"int64"},"example":60}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"string","example":"Molestiae minima.","format":"binary"},"example":"Repellendus quo."}}},"responses":{"200":{"description":"OK response."}}}}},"components":{},"tags":[{"name":"health","description":"Health service provides health check endpoints."},{"name":"cache","description":"Cache service allows storing and retrieving data from distributed cache."}]}
\ No newline at end of file
{"openapi":"3.0.3","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":"1.0"},"servers":[{"url":"http://localhost:8083","description":"Cache Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"},"example":{"service":"Molestiae minima.","status":"Quia dolores rem.","version":"Est illum."}}}}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"},"example":{"service":"Repellendus quo.","status":"Cumque aut.","version":"Sit sint ipsa fugiat et id rem."}}}}}}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get JSON value from the cache.","operationId":"cache#Get","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Rerum et qui alias qui.","format":"binary"},"example":"Accusamus ratione voluptatibus."}}}}},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","operationId":"cache#Set","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","allowEmptyValue":true,"schema":{"type":"integer","description":"Cache entry TTL in seconds","example":60,"format":"int64"},"example":60}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"string","example":"Beatae commodi.","format":"binary"},"example":"Quae minus maiores nulla deleniti ipsa."}}},"responses":{"201":{"description":"Created response."}}}},"/v1/external/cache":{"post":{"tags":["cache"],"summary":"SetExternal cache","description":"Set an external JSON value in the cache and provide an event for the input.","operationId":"cache#SetExternal","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"},{"name":"x-cache-ttl","in":"header","description":"Cache entry TTL in seconds","allowEmptyValue":true,"schema":{"type":"integer","description":"Cache entry TTL in seconds","example":60,"format":"int64"},"example":60}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"string","example":"Fuga voluptas explicabo et libero.","format":"binary"},"example":"Quidem nihil quis tempore."}}},"responses":{"200":{"description":"OK response."}}}}},"components":{"schemas":{"HealthResponse":{"type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Illum nam ratione nisi."},"status":{"type":"string","description":"Status message.","example":"Labore vel."},"version":{"type":"string","description":"Service runtime version.","example":"Aut illum."}},"example":{"service":"Itaque vel.","status":"Itaque enim aut consequatur beatae ut.","version":"Et atque impedit nostrum perspiciatis ipsum."},"required":["service","status","version"]}}},"tags":[{"name":"cache","description":"Cache service allows storing and retrieving data from distributed cache."},{"name":"health","description":"Health service provides health check endpoints."}]}
\ No newline at end of file
......@@ -16,6 +16,14 @@ paths:
responses:
"200":
description: OK response.
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
example:
service: Molestiae minima.
status: Quia dolores rem.
version: Est illum.
/readiness:
get:
tags:
......@@ -25,6 +33,14 @@ paths:
responses:
"200":
description: OK response.
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
example:
service: Repellendus quo.
status: Cumque aut.
version: Sit sint ipsa fugiat et id rem.
/v1/cache:
get:
tags:
......@@ -68,9 +84,9 @@ paths:
application/json:
schema:
type: string
example: Delectus quaerat molestiae placeat nemo.
example: Rerum et qui alias qui.
format: binary
example: Quia dolores rem.
example: Accusamus ratione voluptatibus.
post:
tags:
- cache
......@@ -122,9 +138,9 @@ paths:
application/json:
schema:
type: string
example: Quis rerum velit sunt rerum dignissimos at.
example: Beatae commodi.
format: binary
example: Est illum.
example: Quae minus maiores nulla deleniti ipsa.
responses:
"201":
description: Created response.
......@@ -180,15 +196,39 @@ paths:
application/json:
schema:
type: string
example: Molestiae minima.
example: Fuga voluptas explicabo et libero.
format: binary
example: Repellendus quo.
example: Quidem nihil quis tempore.
responses:
"200":
description: OK response.
components: {}
components:
schemas:
HealthResponse:
type: object
properties:
service:
type: string
description: Service name.
example: Illum nam ratione nisi.
status:
type: string
description: Status message.
example: Labore vel.
version:
type: string
description: Service runtime version.
example: Aut illum.
example:
service: Itaque vel.
status: Itaque enim aut consequatur beatae ut.
version: Et atque impedit nostrum perspiciatis ipsum.
required:
- service
- status
- version
tags:
- name: health
description: Health service provides health check endpoints.
- name: cache
description: Cache service allows storing and retrieving data from distributed cache.
- name: health
description: Health service provides health check endpoints.
package health
import "context"
import (
"context"
type Service struct{}
"gitlab.eclipse.org/eclipse/xfsc/tsa/cache/gen/health"
)
func New() *Service {
return &Service{}
type Service struct {
version string
}
func (s *Service) Liveness(ctx context.Context) error {
return nil
func New(version string) *Service {
return &Service{version: version}
}
func (s *Service) Readiness(ctx context.Context) error {
return nil
func (s *Service) Liveness(_ context.Context) (*health.HealthResponse, error) {
return &health.HealthResponse{
Service: "cache",
Status: "up",
Version: s.version,
}, nil
}
func (s *Service) Readiness(_ context.Context) (*health.HealthResponse, error) {
return &health.HealthResponse{
Service: "cache",
Status: "up",
Version: s.version,
}, nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment