From 7f971ee6c3ad7da307bb13fdda4b03a917d3fda1 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Fri, 28 Apr 2023 21:59:31 +0300 Subject: [PATCH] move to micro v4 Signed-off-by: Vasiliy Tolstov --- README.md | 10 +++++----- go.mod | 8 ++++---- go.sum | 13 ++++--------- handler.go | 14 +++++++------- handler/health/generate.go | 4 ++-- handler/health/health.go | 6 +++--- handler/health/health.proto | 4 ++-- handler/health/health_micro.pb.go | 10 +++++----- handler/health/health_micro_http.pb.go | 10 +++++----- handler/meter/generate.go | 4 ++-- handler/meter/meter.go | 8 ++++---- handler/meter/meter.proto | 4 ++-- handler/meter/meter_micro.pb.go | 10 +++++----- handler/meter/meter_micro_http.pb.go | 10 +++++----- http.go | 14 +++++++------- message.go | 4 ++-- options.go | 2 +- request.go | 6 +++--- server.go | 2 +- subscriber.go | 10 +++++----- util.go | 4 ++-- util_test.go | 2 +- 22 files changed, 77 insertions(+), 82 deletions(-) diff --git a/README.md b/README.md index a32fab6..ddfc0b2 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ to create a HTTP Server that could potentially be used for REST based API servic import ( "net/http" - "github.com/unistack-org/micro/v3/server" - httpServer "github.com/unistack-org/micro-server-http" + "go.unistack.org/micro/v4/server" + httpServer "go.unistack.org/micro-server-http/v4" ) func main() { @@ -37,9 +37,9 @@ Or as part of a service import ( "net/http" - "github.com/unistack-org/micro/v3" - "github.com/unistack-org/micro/v3/server" - httpServer "github.com/unistack-org/micro-server-http" + "go.unistack.org/micro/v4" + "go.unistack.org/micro/v4/server" + httpServer "go.unistack.org/micro-server-http/v4" ) func main() { diff --git a/go.mod b/go.mod index f990118..f3c7063 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ -module go.unistack.org/micro-server-http/v3 +module go.unistack.org/micro-server-http/v4 -go 1.18 +go 1.19 require ( - go.unistack.org/micro-proto/v3 v3.3.1 - go.unistack.org/micro/v3 v3.10.14 + go.unistack.org/micro-proto/v4 v4.0.0 + go.unistack.org/micro/v4 v4.0.1 golang.org/x/net v0.7.0 ) diff --git a/go.sum b/go.sum index b089216..8e7c920 100644 --- a/go.sum +++ b/go.sum @@ -48,17 +48,14 @@ github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/silas/dag v0.0.0-20211117232152-9d50aa809f35/go.mod h1:7RTUFBdIRC9nZ7/3RyRNH1bdqIShrDejd1YbLwgPS+I= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -68,10 +65,10 @@ github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2 github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.unistack.org/micro-proto/v3 v3.3.1 h1:nQ0MtWvP2G3QrpOgawVOPhpZZYkq6umTGDqs8FxJYIo= -go.unistack.org/micro-proto/v3 v3.3.1/go.mod h1:cwRyv8uInM2I7EbU7O8Fx2Ls3N90Uw9UCCcq4olOdfE= -go.unistack.org/micro/v3 v3.10.14 h1:7fgLpwGlCN67twhwtngJDEQvrMkUBDSA5vzZqxIDqNE= -go.unistack.org/micro/v3 v3.10.14/go.mod h1:uMAc0U/x7dmtICCrblGf0ZLgYegu3VwQAquu+OFCw1Q= +go.unistack.org/micro-proto/v4 v4.0.0 h1:+TAwKSlx48eLsNO2E2cO0JLE8we1KU2AuWe9Q310FuU= +go.unistack.org/micro-proto/v4 v4.0.0/go.mod h1:ArmK7o+uFvxSY3dbJhKBBX4Pm1rhWdLEFf3LxBrMtec= +go.unistack.org/micro/v4 v4.0.1 h1:xo1IxbVfgh8i0eY0VeYa3cbb13u5n/Mxnp3FOgWD4Jo= +go.unistack.org/micro/v4 v4.0.1/go.mod h1:p/J5UcSJjfHsWGT31uKoghQ5rUQZzQJBAFy+Z4+ZVMs= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -150,8 +147,6 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/handler.go b/handler.go index c50ac08..a779aeb 100644 --- a/handler.go +++ b/handler.go @@ -9,13 +9,13 @@ import ( "strings" "sync" - "go.unistack.org/micro/v3/errors" - "go.unistack.org/micro/v3/logger" - "go.unistack.org/micro/v3/metadata" - "go.unistack.org/micro/v3/register" - "go.unistack.org/micro/v3/server" - rhttp "go.unistack.org/micro/v3/util/http" - rflutil "go.unistack.org/micro/v3/util/reflect" + "go.unistack.org/micro/v4/errors" + "go.unistack.org/micro/v4/logger" + "go.unistack.org/micro/v4/metadata" + "go.unistack.org/micro/v4/register" + "go.unistack.org/micro/v4/server" + rhttp "go.unistack.org/micro/v4/util/http" + rflutil "go.unistack.org/micro/v4/util/reflect" ) var ( diff --git a/handler/health/generate.go b/handler/health/generate.go index c783863..8df8f29 100644 --- a/handler/health/generate.go +++ b/handler/health/generate.go @@ -1,8 +1,8 @@ package health -//go:generate sh -c "protoc -I./ -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out='components=micro|http|server',standalone=false,debug=true,paths=source_relative:./ health.proto" +//go:generate sh -c "protoc -I./ -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v4) --go-micro_out='components=micro|http|server',standalone=false,debug=true,paths=source_relative:./ health.proto" import ( // import required packages - _ "go.unistack.org/micro-proto/v3/openapiv3" + _ "go.unistack.org/micro-proto/v4/openapiv3" ) diff --git a/handler/health/health.go b/handler/health/health.go index 4399cf3..84467ff 100644 --- a/handler/health/health.go +++ b/handler/health/health.go @@ -1,10 +1,10 @@ -package health // import "go.unistack.org/micro-server-http/v3/handler/health" +package health // import "go.unistack.org/micro-server-http/v4/handler/health" import ( "context" - codecpb "go.unistack.org/micro-proto/v3/codec" - "go.unistack.org/micro/v3/errors" + codecpb "go.unistack.org/micro-proto/v4/codec" + "go.unistack.org/micro/v4/errors" ) var _ HealthServiceServer = &Handler{} diff --git a/handler/health/health.proto b/handler/health/health.proto index 1795501..7986943 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"; +package micro.server.http.v4.handler.health; +option go_package = "go.unistack.org/micro-server-http/v4/handler/health;health"; 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..767aa3a 100644 --- a/handler/health/health_micro.pb.go +++ b/handler/health/health_micro.pb.go @@ -1,22 +1,22 @@ // Code generated by protoc-gen-go-micro. DO NOT EDIT. // versions: -// - protoc-gen-go-micro v3.10.2 -// - protoc v3.21.12 +// - protoc-gen-go-micro v4.10.2 +// - protoc v4.21.12 // source: health.proto package health import ( context "context" - codec "go.unistack.org/micro-proto/v3/codec" - v3 "go.unistack.org/micro-server-http/v3" + codec "go.unistack.org/micro-proto/v4/codec" + v4 "go.unistack.org/micro-server-http/v4" ) var ( HealthServiceName = "HealthService" ) var ( - HealthServiceServerEndpoints = []v3.EndpointMetadata{ + HealthServiceServerEndpoints = []v4.EndpointMetadata{ { Name: "HealthService.Live", Path: "/live", diff --git a/handler/health/health_micro_http.pb.go b/handler/health/health_micro_http.pb.go index 0e3c6e7..b8c2362 100644 --- a/handler/health/health_micro_http.pb.go +++ b/handler/health/health_micro_http.pb.go @@ -1,14 +1,14 @@ // Code generated by protoc-gen-go-micro. DO NOT EDIT. -// protoc-gen-go-micro version: v3.10.2 +// protoc-gen-go-micro version: v4.10.2 // source: health.proto package health import ( context "context" - codec "go.unistack.org/micro-proto/v3/codec" - v3 "go.unistack.org/micro-server-http/v3" - server "go.unistack.org/micro/v3/server" + codec "go.unistack.org/micro-proto/v4/codec" + v4 "go.unistack.org/micro-server-http/v4" + server "go.unistack.org/micro/v4/server" ) type healthServiceServer struct { @@ -38,6 +38,6 @@ func RegisterHealthServiceServer(s server.Server, sh HealthServiceServer, opts . } h := &healthServiceServer{sh} var nopts []server.HandlerOption - nopts = append(nopts, v3.HandlerEndpoints(HealthServiceServerEndpoints)) + nopts = append(nopts, v4.HandlerEndpoints(HealthServiceServerEndpoints)) return s.Handle(s.NewHandler(&HealthService{h}, append(nopts, opts...)...)) } diff --git a/handler/meter/generate.go b/handler/meter/generate.go index 1605764..0342602 100644 --- a/handler/meter/generate.go +++ b/handler/meter/generate.go @@ -1,8 +1,8 @@ package meter -//go:generate sh -c "protoc -I./ -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out='components=micro|http|server',standalone=false,debug=true,paths=source_relative:./ meter.proto" +//go:generate sh -c "protoc -I./ -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v4) --go-micro_out='components=micro|http|server',standalone=false,debug=true,paths=source_relative:./ meter.proto" import ( // import required packages - _ "go.unistack.org/micro-proto/v3/openapiv3" + _ "go.unistack.org/micro-proto/v4/openapiv3" ) diff --git a/handler/meter/meter.go b/handler/meter/meter.go index f92830e..68ea5ba 100644 --- a/handler/meter/meter.go +++ b/handler/meter/meter.go @@ -1,12 +1,12 @@ -package meter // import "go.unistack.org/micro-server-http/v3/handler/meter" +package meter // import "go.unistack.org/micro-server-http/v4/handler/meter" import ( "bytes" "context" - codecpb "go.unistack.org/micro-proto/v3/codec" - "go.unistack.org/micro/v3/errors" - "go.unistack.org/micro/v3/meter" + codecpb "go.unistack.org/micro-proto/v4/codec" + "go.unistack.org/micro/v4/errors" + "go.unistack.org/micro/v4/meter" ) // guard to fail early diff --git a/handler/meter/meter.proto b/handler/meter/meter.proto index 7fc653e..ddf23a0 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"; +package micro.server.http.v4.handler.meter; +option go_package = "go.unistack.org/micro-server-http/v4/handler/meter;meter"; 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..b426725 100644 --- a/handler/meter/meter_micro.pb.go +++ b/handler/meter/meter_micro.pb.go @@ -1,22 +1,22 @@ // Code generated by protoc-gen-go-micro. DO NOT EDIT. // versions: -// - protoc-gen-go-micro v3.10.2 -// - protoc v3.21.12 +// - protoc-gen-go-micro v4.10.2 +// - protoc v4.21.12 // source: meter.proto package meter import ( context "context" - codec "go.unistack.org/micro-proto/v3/codec" - v3 "go.unistack.org/micro-server-http/v3" + codec "go.unistack.org/micro-proto/v4/codec" + v4 "go.unistack.org/micro-server-http/v4" ) var ( MeterServiceName = "MeterService" ) var ( - MeterServiceServerEndpoints = []v3.EndpointMetadata{ + MeterServiceServerEndpoints = []v4.EndpointMetadata{ { Name: "MeterService.Metrics", Path: "/metrics", diff --git a/handler/meter/meter_micro_http.pb.go b/handler/meter/meter_micro_http.pb.go index e79500a..75c2b2a 100644 --- a/handler/meter/meter_micro_http.pb.go +++ b/handler/meter/meter_micro_http.pb.go @@ -1,14 +1,14 @@ // Code generated by protoc-gen-go-micro. DO NOT EDIT. -// protoc-gen-go-micro version: v3.10.2 +// protoc-gen-go-micro version: v4.10.2 // source: meter.proto package meter import ( context "context" - codec "go.unistack.org/micro-proto/v3/codec" - v3 "go.unistack.org/micro-server-http/v3" - server "go.unistack.org/micro/v3/server" + codec "go.unistack.org/micro-proto/v4/codec" + v4 "go.unistack.org/micro-server-http/v4" + server "go.unistack.org/micro/v4/server" ) type meterServiceServer struct { @@ -28,6 +28,6 @@ func RegisterMeterServiceServer(s server.Server, sh MeterServiceServer, opts ... } h := &meterServiceServer{sh} var nopts []server.HandlerOption - nopts = append(nopts, v3.HandlerEndpoints(MeterServiceServerEndpoints)) + nopts = append(nopts, v4.HandlerEndpoints(MeterServiceServerEndpoints)) return s.Handle(s.NewHandler(&MeterService{h}, append(nopts, opts...)...)) } diff --git a/http.go b/http.go index d23d01d..f447a0f 100644 --- a/http.go +++ b/http.go @@ -1,5 +1,5 @@ // Package http implements a go-micro.Server -package http // import "go.unistack.org/micro-server-http/v3" +package http // import "go.unistack.org/micro-server-http/v4" import ( "context" @@ -14,12 +14,12 @@ import ( "sync" "time" - "go.unistack.org/micro/v3/broker" - "go.unistack.org/micro/v3/codec" - "go.unistack.org/micro/v3/logger" - "go.unistack.org/micro/v3/register" - "go.unistack.org/micro/v3/server" - rhttp "go.unistack.org/micro/v3/util/http" + "go.unistack.org/micro/v4/broker" + "go.unistack.org/micro/v4/codec" + "go.unistack.org/micro/v4/logger" + "go.unistack.org/micro/v4/register" + "go.unistack.org/micro/v4/server" + rhttp "go.unistack.org/micro/v4/util/http" "golang.org/x/net/netutil" ) diff --git a/message.go b/message.go index 2146e5c..40e14de 100644 --- a/message.go +++ b/message.go @@ -1,8 +1,8 @@ package http import ( - "go.unistack.org/micro/v3/codec" - "go.unistack.org/micro/v3/metadata" + "go.unistack.org/micro/v4/codec" + "go.unistack.org/micro/v4/metadata" ) type httpMessage struct { diff --git a/options.go b/options.go index 3825d11..3e6fde1 100644 --- a/options.go +++ b/options.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "go.unistack.org/micro/v3/server" + "go.unistack.org/micro/v4/server" ) // SetError pass error to caller diff --git a/request.go b/request.go index 092f33e..16ac60b 100644 --- a/request.go +++ b/request.go @@ -3,9 +3,9 @@ package http import ( "io" - "go.unistack.org/micro/v3/codec" - "go.unistack.org/micro/v3/metadata" - "go.unistack.org/micro/v3/server" + "go.unistack.org/micro/v4/codec" + "go.unistack.org/micro/v4/metadata" + "go.unistack.org/micro/v4/server" ) var ( diff --git a/server.go b/server.go index 7508467..8ea0da0 100644 --- a/server.go +++ b/server.go @@ -7,7 +7,7 @@ import ( "unicode" "unicode/utf8" - "go.unistack.org/micro/v3/server" + "go.unistack.org/micro/v4/server" ) type methodType struct { diff --git a/subscriber.go b/subscriber.go index 974ec06..9889c9d 100644 --- a/subscriber.go +++ b/subscriber.go @@ -7,11 +7,11 @@ import ( "reflect" "strings" - "go.unistack.org/micro/v3/broker" - "go.unistack.org/micro/v3/codec" - "go.unistack.org/micro/v3/metadata" - "go.unistack.org/micro/v3/register" - "go.unistack.org/micro/v3/server" + "go.unistack.org/micro/v4/broker" + "go.unistack.org/micro/v4/codec" + "go.unistack.org/micro/v4/metadata" + "go.unistack.org/micro/v4/register" + "go.unistack.org/micro/v4/server" ) var typeOfError = reflect.TypeOf((*error)(nil)).Elem() diff --git a/util.go b/util.go index 99576d3..83cc8fa 100644 --- a/util.go +++ b/util.go @@ -5,8 +5,8 @@ import ( "net/http" "strings" - "go.unistack.org/micro/v3/metadata" - rutil "go.unistack.org/micro/v3/util/reflect" + "go.unistack.org/micro/v4/metadata" + rutil "go.unistack.org/micro/v4/util/reflect" ) func FillRequest(ctx context.Context, req interface{}, opts ...FillRequestOption) error { diff --git a/util_test.go b/util_test.go index 76c7cd3..515f734 100644 --- a/util_test.go +++ b/util_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "go.unistack.org/micro/v3/metadata" + "go.unistack.org/micro/v4/metadata" ) func TestFillrequest(t *testing.T) {