From 1c36c1685f85dff3e99d2c299baac91f49273171 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 10 Apr 2024 00:15:54 +0300 Subject: [PATCH] regen Signed-off-by: Vasiliy Tolstov --- handler/health/health.proto | 2 +- handler/health/health_micro.pb.go | 41 +++------- handler/health/health_micro_http.pb.go | 98 ++++++++++++++++++++++- handler/meter/meter.proto | 2 +- handler/meter/meter_micro.pb.go | 25 +++--- handler/meter/meter_micro_http.pb.go | 48 ++++++++++- handler/swagger-ui/swagger-initializer.js | 20 ----- handler/swagger-ui/swaggerui_test.go | 2 +- http.go | 6 +- 9 files changed, 166 insertions(+), 78 deletions(-) delete mode 100644 handler/swagger-ui/swagger-initializer.js diff --git a/handler/health/health.proto b/handler/health/health.proto index 1795501..6a23f99 100644 --- a/handler/health/health.proto +++ b/handler/health/health.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package micro.server.http.v3.handler.health; -option go_package = "go.unistack.org/micro-server-http/v3/handler/health;health"; +option go_package = "go.unistack.org/micro-server-http/v3/handler/health;health_handler"; import "api/annotations.proto"; import "openapiv3/annotations.proto"; diff --git a/handler/health/health_micro.pb.go b/handler/health/health_micro.pb.go index 3e6f6a0..cfbb869 100644 --- a/handler/health/health_micro.pb.go +++ b/handler/health/health_micro.pb.go @@ -1,45 +1,26 @@ // Code generated by protoc-gen-go-micro. DO NOT EDIT. // versions: -// - protoc-gen-go-micro v3.10.2 -// - protoc v3.21.12 -// source: health.proto +// - protoc-gen-go-micro v3.10.4 +// - protoc v5.26.1 +// source: health/health.proto -package health +package health_handler import ( context "context" codec "go.unistack.org/micro-proto/v3/codec" - v3 "go.unistack.org/micro-server-http/v3" + client "go.unistack.org/micro/v3/client" ) var ( HealthServiceName = "HealthService" ) -var ( - HealthServiceServerEndpoints = []v3.EndpointMetadata{ - { - Name: "HealthService.Live", - Path: "/live", - Method: "GET", - Body: "", - Stream: false, - }, - { - Name: "HealthService.Ready", - Path: "/ready", - Method: "GET", - Body: "", - Stream: false, - }, - { - Name: "HealthService.Version", - Path: "/version", - Method: "GET", - Body: "", - Stream: false, - }, - } -) + +type HealthServiceClient interface { + Live(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) + Ready(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) + Version(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) +} type HealthServiceServer interface { Live(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error diff --git a/handler/health/health_micro_http.pb.go b/handler/health/health_micro_http.pb.go index 0e3c6e7..75e4d85 100644 --- a/handler/health/health_micro_http.pb.go +++ b/handler/health/health_micro_http.pb.go @@ -1,16 +1,108 @@ // Code generated by protoc-gen-go-micro. DO NOT EDIT. -// protoc-gen-go-micro version: v3.10.2 -// source: health.proto +// protoc-gen-go-micro version: v3.10.4 +// source: health/health.proto -package health +package health_handler import ( context "context" + v31 "go.unistack.org/micro-client-http/v3" codec "go.unistack.org/micro-proto/v3/codec" v3 "go.unistack.org/micro-server-http/v3" + client "go.unistack.org/micro/v3/client" server "go.unistack.org/micro/v3/server" + http "net/http" ) +var ( + HealthServiceServerEndpoints = []v3.EndpointMetadata{ + { + Name: "HealthService.Live", + Path: "/live", + Method: "GET", + Body: "", + Stream: false, + }, + { + Name: "HealthService.Ready", + Path: "/ready", + Method: "GET", + Body: "", + Stream: false, + }, + { + Name: "HealthService.Version", + Path: "/version", + Method: "GET", + Body: "", + Stream: false, + }, + } +) + +type healthServiceClient struct { + c client.Client + name string +} + +func NewHealthServiceClient(name string, c client.Client) HealthServiceClient { + return &healthServiceClient{c: c, name: name} +} + +func (c *healthServiceClient) Live(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) { + errmap := make(map[string]interface{}, 1) + errmap["default"] = &codec.Frame{} + opts = append(opts, + v31.ErrorMap(errmap), + ) + opts = append(opts, + v31.Method(http.MethodGet), + v31.Path("/live"), + ) + rsp := &codec.Frame{} + err := c.c.Call(ctx, c.c.NewRequest(c.name, "HealthService.Live", req), rsp, opts...) + if err != nil { + return nil, err + } + return rsp, nil +} + +func (c *healthServiceClient) Ready(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) { + errmap := make(map[string]interface{}, 1) + errmap["default"] = &codec.Frame{} + opts = append(opts, + v31.ErrorMap(errmap), + ) + opts = append(opts, + v31.Method(http.MethodGet), + v31.Path("/ready"), + ) + rsp := &codec.Frame{} + err := c.c.Call(ctx, c.c.NewRequest(c.name, "HealthService.Ready", req), rsp, opts...) + if err != nil { + return nil, err + } + return rsp, nil +} + +func (c *healthServiceClient) Version(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) { + errmap := make(map[string]interface{}, 1) + errmap["default"] = &codec.Frame{} + opts = append(opts, + v31.ErrorMap(errmap), + ) + opts = append(opts, + v31.Method(http.MethodGet), + v31.Path("/version"), + ) + rsp := &codec.Frame{} + err := c.c.Call(ctx, c.c.NewRequest(c.name, "HealthService.Version", req), rsp, opts...) + if err != nil { + return nil, err + } + return rsp, nil +} + type healthServiceServer struct { HealthServiceServer } diff --git a/handler/meter/meter.proto b/handler/meter/meter.proto index 7fc653e..ef08f72 100644 --- a/handler/meter/meter.proto +++ b/handler/meter/meter.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package micro.server.http.v3.handler.meter; -option go_package = "go.unistack.org/micro-server-http/v3/handler/meter;meter"; +option go_package = "go.unistack.org/micro-server-http/v3/handler/meter;meter_handler"; import "api/annotations.proto"; import "openapiv3/annotations.proto"; diff --git a/handler/meter/meter_micro.pb.go b/handler/meter/meter_micro.pb.go index d9ba8aa..1b9ed6f 100644 --- a/handler/meter/meter_micro.pb.go +++ b/handler/meter/meter_micro.pb.go @@ -1,31 +1,24 @@ // Code generated by protoc-gen-go-micro. DO NOT EDIT. // versions: -// - protoc-gen-go-micro v3.10.2 -// - protoc v3.21.12 -// source: meter.proto +// - protoc-gen-go-micro v3.10.4 +// - protoc v5.26.1 +// source: meter/meter.proto -package meter +package meter_handler import ( context "context" codec "go.unistack.org/micro-proto/v3/codec" - v3 "go.unistack.org/micro-server-http/v3" + client "go.unistack.org/micro/v3/client" ) var ( MeterServiceName = "MeterService" ) -var ( - MeterServiceServerEndpoints = []v3.EndpointMetadata{ - { - Name: "MeterService.Metrics", - Path: "/metrics", - Method: "GET", - Body: "", - Stream: false, - }, - } -) + +type MeterServiceClient interface { + Metrics(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) +} type MeterServiceServer interface { Metrics(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error diff --git a/handler/meter/meter_micro_http.pb.go b/handler/meter/meter_micro_http.pb.go index e79500a..2eccdf6 100644 --- a/handler/meter/meter_micro_http.pb.go +++ b/handler/meter/meter_micro_http.pb.go @@ -1,16 +1,58 @@ // Code generated by protoc-gen-go-micro. DO NOT EDIT. -// protoc-gen-go-micro version: v3.10.2 -// source: meter.proto +// protoc-gen-go-micro version: v3.10.4 +// source: meter/meter.proto -package meter +package meter_handler import ( context "context" + v31 "go.unistack.org/micro-client-http/v3" codec "go.unistack.org/micro-proto/v3/codec" v3 "go.unistack.org/micro-server-http/v3" + client "go.unistack.org/micro/v3/client" server "go.unistack.org/micro/v3/server" + http "net/http" ) +var ( + MeterServiceServerEndpoints = []v3.EndpointMetadata{ + { + Name: "MeterService.Metrics", + Path: "/metrics", + Method: "GET", + Body: "", + Stream: false, + }, + } +) + +type meterServiceClient struct { + c client.Client + name string +} + +func NewMeterServiceClient(name string, c client.Client) MeterServiceClient { + return &meterServiceClient{c: c, name: name} +} + +func (c *meterServiceClient) Metrics(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) { + errmap := make(map[string]interface{}, 1) + errmap["default"] = &codec.Frame{} + opts = append(opts, + v31.ErrorMap(errmap), + ) + opts = append(opts, + v31.Method(http.MethodGet), + v31.Path("/metrics"), + ) + rsp := &codec.Frame{} + err := c.c.Call(ctx, c.c.NewRequest(c.name, "MeterService.Metrics", req), rsp, opts...) + if err != nil { + return nil, err + } + return rsp, nil +} + type meterServiceServer struct { MeterServiceServer } diff --git a/handler/swagger-ui/swagger-initializer.js b/handler/swagger-ui/swagger-initializer.js deleted file mode 100644 index 780b173..0000000 --- a/handler/swagger-ui/swagger-initializer.js +++ /dev/null @@ -1,20 +0,0 @@ -window.onload = function() { - // - - // the following lines will be replaced by docker/configurator, when it runs in a docker-container - window.ui = SwaggerUIBundle({ - url: "{{ .SWAGGER }}", - dom_id: '#swagger-ui', - deepLinking: true, - presets: [ - SwaggerUIBundle.presets.apis, - SwaggerUIStandalonePreset - ], - plugins: [ - SwaggerUIBundle.plugins.DownloadUrl - ], - layout: "StandaloneLayout" - }); - - // -}; diff --git a/handler/swagger-ui/swaggerui_test.go b/handler/swagger-ui/swaggerui_test.go index 0e4d8a3..88e068a 100644 --- a/handler/swagger-ui/swaggerui_test.go +++ b/handler/swagger-ui/swaggerui_test.go @@ -1,4 +1,4 @@ -package swaggerui +package swaggerui_handler import ( "net/http" diff --git a/http.go b/http.go index 52fa01d..233ad2c 100644 --- a/http.go +++ b/http.go @@ -561,7 +561,7 @@ func (h *Server) Start() error { if err := config.RegisterCheck(h.opts.Context); err != nil { if config.Logger.V(logger.ErrorLevel) { - config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register check error", config.Name, config.ID) err) + config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register check error", config.Name, config.ID), err) } } else { if err = h.Register(); err != nil { @@ -621,7 +621,7 @@ func (h *Server) Start() error { // nolint: nestif if rerr != nil && registered { if config.Logger.V(logger.ErrorLevel) { - config.Logger.Error(config.Context,fmt.Sprintf("Server %s-%s register check error, deregister it", config.Name, config.ID), rerr) + config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register check error, deregister it", config.Name, config.ID), rerr) } // deregister self in case of error if err := h.Deregister(); err != nil { @@ -637,7 +637,7 @@ func (h *Server) Start() error { } if err := h.Register(); err != nil { if config.Logger.V(logger.ErrorLevel) { - config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register error: %s", config.Name, config.ID), err) + config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register error", config.Name, config.ID), err) } }