From c53c20904e222587ea5d0789be10c2ac335e29c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B4=AA=E6=B3=A2?= Date: Sun, 13 Dec 2020 00:25:55 +0800 Subject: [PATCH 1/2] rename gateway --- README.md | 2 +- service/gateway/Dockerfile | 8 --- service/gateway/Makefile | 19 ------ service/gateway/api/api.go | 47 ------------- service/gateway/stack_config.yml | 25 ------- service/{gateway => stackway}/.gitignore | 0 service/stackway/Dockerfile | 8 +++ service/stackway/Makefile | 24 +++++++ service/{gateway => stackway}/README.md | 7 +- service/stackway/api/api.go | 46 +++++++++++++ service/{gateway => stackway}/api/http.go | 19 +++--- .../{gateway => stackway}/api/http_test.go | 0 .../{gateway => stackway}/api/proto/api.pb.go | 66 +++++++++---------- .../api/proto/api.pb.stack.go | 2 +- .../{gateway => stackway}/api/proto/api.proto | 0 service/{gateway => stackway}/go.mod | 2 +- service/{gateway => stackway}/go.sum | 0 service/{gateway => stackway}/handler/meta.go | 0 service/{gateway => stackway}/handler/rpc.go | 2 +- .../{gateway => stackway}/handler/rpc_test.go | 2 +- .../{gateway => stackway}/helper/helper.go | 0 .../helper/helper_test.go | 0 .../service.go => stackway/hook/hook.go} | 11 ++-- .../hook/hook_test.go} | 10 +-- service/{gateway/cmd => stackway}/main.go | 4 +- .../{gateway => stackway}/plugin/README.md | 0 .../plugin/build/commands.go | 5 +- .../{gateway => stackway}/plugin/manager.go | 0 .../{gateway => stackway}/plugin/options.go | 0 .../{gateway => stackway}/plugin/plugin.go | 0 .../{gateway => stackway}/server/options.go | 2 +- .../{gateway => stackway}/server/server.go | 34 +++++----- .../conf => stackway}/stack_config.yml | 6 +- .../test/handler/handler.go | 3 +- .../test/proto/test.pb.go | 52 ++++++++------- .../test/proto/test.pb.stack.go | 4 +- .../test/proto/test.proto | 2 +- 37 files changed, 198 insertions(+), 214 deletions(-) delete mode 100644 service/gateway/Dockerfile delete mode 100644 service/gateway/Makefile delete mode 100644 service/gateway/api/api.go delete mode 100644 service/gateway/stack_config.yml rename service/{gateway => stackway}/.gitignore (100%) create mode 100644 service/stackway/Dockerfile create mode 100644 service/stackway/Makefile rename service/{gateway => stackway}/README.md (74%) create mode 100644 service/stackway/api/api.go rename service/{gateway => stackway}/api/http.go (94%) rename service/{gateway => stackway}/api/http_test.go (100%) rename service/{gateway => stackway}/api/proto/api.pb.go (71%) rename service/{gateway => stackway}/api/proto/api.pb.stack.go (87%) rename service/{gateway => stackway}/api/proto/api.proto (100%) rename service/{gateway => stackway}/go.mod (85%) rename service/{gateway => stackway}/go.sum (100%) rename service/{gateway => stackway}/handler/meta.go (100%) rename service/{gateway => stackway}/handler/rpc.go (98%) rename service/{gateway => stackway}/handler/rpc_test.go (99%) rename service/{gateway => stackway}/helper/helper.go (100%) rename service/{gateway => stackway}/helper/helper_test.go (100%) rename service/{gateway/service.go => stackway/hook/hook.go} (74%) rename service/{gateway/service_test.go => stackway/hook/hook_test.go} (95%) rename service/{gateway/cmd => stackway}/main.go (77%) rename service/{gateway => stackway}/plugin/README.md (100%) rename service/{gateway => stackway}/plugin/build/commands.go (95%) rename service/{gateway => stackway}/plugin/manager.go (100%) rename service/{gateway => stackway}/plugin/options.go (100%) rename service/{gateway => stackway}/plugin/plugin.go (100%) rename service/{gateway => stackway}/server/options.go (97%) rename service/{gateway => stackway}/server/server.go (89%) rename service/{gateway/conf => stackway}/stack_config.yml (83%) rename service/{gateway => stackway}/test/handler/handler.go (86%) rename service/{gateway => stackway}/test/proto/test.pb.go (59%) rename service/{gateway => stackway}/test/proto/test.pb.stack.go (96%) rename service/{gateway => stackway}/test/proto/test.proto (91%) diff --git a/README.md b/README.md index 8429149..23f209f 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,4 @@ - [etcd](./registry/etcd) ETCD配置中心 - [zookeeper](./registry/zookeeper) Zookeeper配置中心 - Service - - [gateway](./service/gateway) 网关 \ No newline at end of file + - [stackway](service/stackway) 网关 diff --git a/service/gateway/Dockerfile b/service/gateway/Dockerfile deleted file mode 100644 index fb09bed..0000000 --- a/service/gateway/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM alpine:3.10 - -ADD conf/stack_config.yml /bin/stack_config.yml -ADD bin/gateway /bin/gateway - -WORKDIR /bin -ENTRYPOINT [ "gateway" ] -CMD [ "--config", "stack_config.yml" ] diff --git a/service/gateway/Makefile b/service/gateway/Makefile deleted file mode 100644 index 4641f55..0000000 --- a/service/gateway/Makefile +++ /dev/null @@ -1,19 +0,0 @@ - -GOPATH:=$(shell go env GOPATH) - -.PHONY: test -test: - go test -race -cover -v ./... - -.PHONY: run -run: - go run cmd/main.go --config conf/stack_config.yml - -.PHONY: build -build: - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags '-w' -o ./bin/gateway cmd/main.go - -.PHONY: docker -docker: build - docker build . -t $(tag) - diff --git a/service/gateway/api/api.go b/service/gateway/api/api.go deleted file mode 100644 index b839ff6..0000000 --- a/service/gateway/api/api.go +++ /dev/null @@ -1,47 +0,0 @@ -// Package api is an API Gateway -package api - -import ( - "github.com/stack-labs/stack-rpc" - "github.com/stack-labs/stack-rpc/pkg/cli" -) - -// api gateway options -func Options() (options []stack.Option) { - flags := []cli.Flag{ - cli.StringFlag{ - Name: "gateway_name", - Usage: "Gateway name", - EnvVar: "STACK_GATEWAY_NAME", - }, - cli.StringFlag{ - Name: "gateway_address", - Usage: "Set the gateway address e.g 0.0.0.0:8080", - EnvVar: "STACK_GATEWAY_ADDRESS", - }, - cli.StringFlag{ - Name: "gateway_handler", - Usage: "Specify the request handler to be used for mapping HTTP requests to services; {api, event, http, rpc}", - EnvVar: "STACK_GATEWAY_HANDLER", - }, - cli.StringFlag{ - Name: "gateway_namespace", - Usage: "Set the namespace used by the gateway e.g. com.example.gateway", - EnvVar: "STACK_GATEWAY_NAMESPACE", - }, - cli.StringFlag{ - Name: "gateway_resolver", - Usage: "Set the hostname resolver used by the gateway {host, path, grpc}", - EnvVar: "STACK_GATEWAY_RESOLVER", - }, - cli.BoolFlag{ - Name: "gateway_enable_rpc", - Usage: "Enable call the backend directly via /rpc", - EnvVar: "STACK_GATEWAY_ENABLE_RPC", - }, - } - - options = append(options, stack.Flags(flags...)) - - return -} diff --git a/service/gateway/stack_config.yml b/service/gateway/stack_config.yml deleted file mode 100644 index 301f3f8..0000000 --- a/service/gateway/stack_config.yml +++ /dev/null @@ -1,25 +0,0 @@ -stack: - registry: - name: mdns - - gateway: - address: :8080 # gateway serve address - handler: "meta" - resolver: "stack" - rpc_path: "/rpc" - api_path: "/" - proxy_path: "/{service:[a-zA-Z0-9]+}" - namespace: "stack.rpc.api" - header_prefix: "X-Stack-" - enable_rpc: true - enable_acme: false - enable_tls: false - acme: - provider: "autocert" - challenge_provider: "cloudflare" - ca: "https://acme-v02.api.letsencrypt.org/directory" - hosts: - - "" - # Plugins - example: - key: value diff --git a/service/gateway/.gitignore b/service/stackway/.gitignore similarity index 100% rename from service/gateway/.gitignore rename to service/stackway/.gitignore diff --git a/service/stackway/Dockerfile b/service/stackway/Dockerfile new file mode 100644 index 0000000..0da9a58 --- /dev/null +++ b/service/stackway/Dockerfile @@ -0,0 +1,8 @@ +FROM alpine:3.10 + +ADD stack_config.yml /bin/stack_config.yml +ADD bin/stackway /bin/stackway + +WORKDIR /bin +ENTRYPOINT [ "stackway" ] +CMD [ "--config", "stack_config.yml" ] diff --git a/service/stackway/Makefile b/service/stackway/Makefile new file mode 100644 index 0000000..a3d5c7a --- /dev/null +++ b/service/stackway/Makefile @@ -0,0 +1,24 @@ + +GOPATH:=$(shell go env GOPATH) + +.PHONY: proto +proto: + protoc --proto_path=${GOPATH}/src --stack_out=${GOPATH}/src --go_out=:${GOPATH}/src github.com/stack-labs/stack-rpc-plugins/service/stackway/api/proto/api.proto + protoc --proto_path=${GOPATH}/src --stack_out=${GOPATH}/src --go_out=:${GOPATH}/src github.com/stack-labs/stack-rpc-plugins/service/stackway/test/proto/test.proto + +.PHONY: test +test: + go test -race -cover -v ./... + +.PHONY: run +run: + go run main.go --config stack_config.yml + +.PHONY: build +build: + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags '-w' -o ./bin/stackway main.go + +.PHONY: docker +docker: build + docker build . -t $(tag) + diff --git a/service/gateway/README.md b/service/stackway/README.md similarity index 74% rename from service/gateway/README.md rename to service/stackway/README.md index cd9449f..bb7aa0b 100644 --- a/service/gateway/README.md +++ b/service/stackway/README.md @@ -1,12 +1,11 @@ -# Gateway +# Stackway `cmd`目录为网关简单用例,包括`yml`配置以及`plugin`的示范 ```shell script -$ cd cmd $ go run main.go plugin.go --config=stack_config.yml ``` - 如果作为单纯网关,不需要启动`server`,配置中`stack.server.protocol`可以使用`mock` -- `example`插件配置可以自己定义,示范的配置层级为`gateway.example`,对应代码段: - - `cfg.Get("gateway", "example").Scan(&conf)` +- `example`插件配置可以自己定义,示范的配置层级为`stackway.example`,对应代码段: + - `cfg.Get("stackway", "example").Scan(&conf)` diff --git a/service/stackway/api/api.go b/service/stackway/api/api.go new file mode 100644 index 0000000..f8e2fd8 --- /dev/null +++ b/service/stackway/api/api.go @@ -0,0 +1,46 @@ +package api + +import ( + "github.com/stack-labs/stack-rpc" + "github.com/stack-labs/stack-rpc/pkg/cli" +) + +// api stackway options +func Options() (options []stack.Option) { + flags := []cli.Flag{ + cli.StringFlag{ + Name: "stackway_name", + Usage: "Stackway name", + EnvVar: "STACK_STACKWAY_NAME", + }, + cli.StringFlag{ + Name: "stackway_address", + Usage: "Set the stackway address e.g 0.0.0.0:8080", + EnvVar: "STACK_STACKWAY_ADDRESS", + }, + cli.StringFlag{ + Name: "stackway_handler", + Usage: "Specify the request handler to be used for mapping HTTP requests to services; {api, event, http, rpc}", + EnvVar: "STACK_STACKWAY_HANDLER", + }, + cli.StringFlag{ + Name: "stackway_namespace", + Usage: "Set the namespace used by the stackway e.g. stack.rpc.api", + EnvVar: "STACK_STACKWAY_NAMESPACE", + }, + cli.StringFlag{ + Name: "stackway_resolver", + Usage: "Set the hostname resolver used by the stackway {host, path, grpc}", + EnvVar: "STACK_STACKWAY_RESOLVER", + }, + cli.BoolFlag{ + Name: "stackway_enable_rpc", + Usage: "Enable call the backend directly via /rpc", + EnvVar: "STACK_STACKWAY_ENABLE_RPC", + }, + } + + options = append(options, stack.Flags(flags...)) + + return +} diff --git a/service/gateway/api/http.go b/service/stackway/api/http.go similarity index 94% rename from service/gateway/api/http.go rename to service/stackway/api/http.go index 82de001..5b95de8 100644 --- a/service/gateway/api/http.go +++ b/service/stackway/api/http.go @@ -1,4 +1,3 @@ -// Package api is an API Gateway package api import ( @@ -7,7 +6,7 @@ import ( "github.com/gorilla/mux" "github.com/stack-labs/stack-rpc" - gwServer "github.com/stack-labs/stack-rpc-plugins/service/gateway/server" + gwServer "github.com/stack-labs/stack-rpc-plugins/service/stackway/server" ahandler "github.com/stack-labs/stack-rpc/api/handler" aapi "github.com/stack-labs/stack-rpc/api/handler/api" "github.com/stack-labs/stack-rpc/api/handler/event" @@ -28,17 +27,17 @@ import ( stackConfig "github.com/stack-labs/stack-rpc/config" "github.com/stack-labs/stack-rpc/util/log" - "github.com/stack-labs/stack-rpc-plugins/service/gateway/handler" - "github.com/stack-labs/stack-rpc-plugins/service/gateway/helper" - "github.com/stack-labs/stack-rpc-plugins/service/gateway/plugin" + "github.com/stack-labs/stack-rpc-plugins/service/stackway/handler" + "github.com/stack-labs/stack-rpc-plugins/service/stackway/helper" + "github.com/stack-labs/stack-rpc-plugins/service/stackway/plugin" ) type config struct { - Server *stackConfig.Server `json:"server"` - Gateway *gateway `json:"gateway"` + Server *stackConfig.Server `json:"server"` + Stackway *stackway `json:"stackway"` } -type gateway struct { +type stackway struct { Address string `json:"address"` Handler string `json:"handler"` Resolver string `json:"resolver"` @@ -66,7 +65,7 @@ func newDefaultConfig() *config { Server: &stackConfig.Server{ Address: ":8080", }, - Gateway: &gateway{ + Stackway: &stackway{ Handler: "meta", Resolver: "stack", RPCPath: "/rpc", @@ -113,7 +112,7 @@ func (s *httpServer) Start() error { } } - gwConf := conf.Gateway + gwConf := conf.Stackway address := conf.Server.Address if len(gwConf.Address) > 0 { address = gwConf.Address diff --git a/service/gateway/api/http_test.go b/service/stackway/api/http_test.go similarity index 100% rename from service/gateway/api/http_test.go rename to service/stackway/api/http_test.go diff --git a/service/gateway/api/proto/api.pb.go b/service/stackway/api/proto/api.pb.go similarity index 71% rename from service/gateway/api/proto/api.pb.go rename to service/stackway/api/proto/api.pb.go index 9ab6c84..c684334 100644 --- a/service/gateway/api/proto/api.pb.go +++ b/service/stackway/api/proto/api.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: github.com/stack-labs/stack-rpc-plugins/service/gateway/api/proto/api.proto +// source: github.com/stack-labs/stack-rpc-plugins/service/stackway/api/proto/api.proto package stack_rpc_api @@ -32,7 +32,7 @@ func (m *Pair) Reset() { *m = Pair{} } func (m *Pair) String() string { return proto.CompactTextString(m) } func (*Pair) ProtoMessage() {} func (*Pair) Descriptor() ([]byte, []int) { - return fileDescriptor_254013c1e2f5907a, []int{0} + return fileDescriptor_e5e9b8f29cbb979d, []int{0} } func (m *Pair) XXX_Unmarshal(b []byte) error { @@ -84,7 +84,7 @@ func (m *Request) Reset() { *m = Request{} } func (m *Request) String() string { return proto.CompactTextString(m) } func (*Request) ProtoMessage() {} func (*Request) Descriptor() ([]byte, []int) { - return fileDescriptor_254013c1e2f5907a, []int{1} + return fileDescriptor_e5e9b8f29cbb979d, []int{1} } func (m *Request) XXX_Unmarshal(b []byte) error { @@ -167,7 +167,7 @@ func (m *Response) Reset() { *m = Response{} } func (m *Response) String() string { return proto.CompactTextString(m) } func (*Response) ProtoMessage() {} func (*Response) Descriptor() ([]byte, []int) { - return fileDescriptor_254013c1e2f5907a, []int{2} + return fileDescriptor_e5e9b8f29cbb979d, []int{2} } func (m *Response) XXX_Unmarshal(b []byte) error { @@ -220,33 +220,33 @@ func init() { } func init() { - proto.RegisterFile("github.com/stack-labs/stack-rpc-plugins/service/gateway/api/proto/api.proto", fileDescriptor_254013c1e2f5907a) -} - -var fileDescriptor_254013c1e2f5907a = []byte{ - // 376 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xdd, 0x6e, 0xda, 0x30, - 0x1c, 0xc5, 0x95, 0x0f, 0x02, 0xfc, 0xd1, 0xa4, 0xc9, 0x93, 0x26, 0x8b, 0x8b, 0x2d, 0xca, 0x6e, - 0xd8, 0x05, 0xc9, 0xc6, 0x76, 0x51, 0xd1, 0xcb, 0xaa, 0x6a, 0x25, 0xaa, 0x0a, 0xe5, 0x0d, 0x9c, - 0xc4, 0x4a, 0x22, 0x02, 0x76, 0x6d, 0x87, 0x2a, 0xcf, 0xd8, 0x47, 0xe9, 0x4b, 0x54, 0x76, 0x02, - 0xa5, 0x2d, 0x5c, 0xd1, 0xbb, 0x63, 0xeb, 0x9c, 0xc3, 0xe1, 0x67, 0x05, 0x16, 0x79, 0xa9, 0x8a, - 0x3a, 0x09, 0x53, 0xb6, 0x8e, 0xa4, 0x22, 0xe9, 0x6a, 0x5a, 0x91, 0x44, 0x76, 0x52, 0xf0, 0x74, - 0xca, 0xab, 0x3a, 0x2f, 0x37, 0x32, 0x92, 0x54, 0x6c, 0xcb, 0x94, 0x46, 0x39, 0x51, 0xf4, 0x91, - 0x34, 0x11, 0xe1, 0x65, 0xc4, 0x05, 0x53, 0x4c, 0xab, 0xd0, 0x28, 0xf4, 0xc5, 0xc4, 0x42, 0xc1, - 0xd3, 0x90, 0xf0, 0x32, 0xf8, 0x03, 0xee, 0x92, 0x94, 0x02, 0x7d, 0x05, 0x67, 0x45, 0x1b, 0x6c, - 0xf9, 0xd6, 0x64, 0x18, 0x6b, 0x89, 0xbe, 0x83, 0xb7, 0x25, 0x55, 0x4d, 0x25, 0xb6, 0x7d, 0x67, - 0x32, 0x8c, 0xbb, 0x53, 0xf0, 0x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xe3, 0x1d, 0x7a, - 0xe7, 0x15, 0xfd, 0x67, 0x83, 0x4e, 0x3c, 0xf3, 0x0d, 0xfc, 0x7b, 0x09, 0x00, 0x00, 0xff, 0xff, - 0xe3, 0xe1, 0x9a, 0xa8, 0x52, 0x03, 0x00, 0x00, + proto.RegisterFile("github.com/stack-labs/stack-rpc-plugins/service/stackway/api/proto/api.proto", fileDescriptor_e5e9b8f29cbb979d) +} + +var fileDescriptor_e5e9b8f29cbb979d = []byte{ + // 375 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0x4f, 0x6e, 0xe2, 0x30, + 0x18, 0xc5, 0x95, 0x3f, 0x04, 0xf8, 0xd0, 0x48, 0x23, 0x8f, 0x34, 0xb2, 0x58, 0xcc, 0x44, 0x99, + 0x0d, 0xb3, 0x20, 0x69, 0x69, 0x17, 0x15, 0x5d, 0x56, 0x55, 0x2b, 0x15, 0x55, 0x28, 0x37, 0x70, + 0x12, 0x8b, 0x44, 0x04, 0xec, 0xda, 0x0e, 0x55, 0xce, 0xd8, 0xa3, 0xf4, 0x12, 0x95, 0x9d, 0x40, + 0x69, 0x0b, 0x2b, 0xba, 0x7b, 0xb6, 0xbf, 0xf7, 0xf2, 0xf2, 0xb3, 0x0c, 0xb3, 0x45, 0xa1, 0xf2, + 0x2a, 0x09, 0x53, 0xb6, 0x8a, 0xa4, 0x22, 0xe9, 0x72, 0x5c, 0x92, 0x44, 0xb6, 0x52, 0xf0, 0x74, + 0xcc, 0xcb, 0x6a, 0x51, 0xac, 0x65, 0x24, 0xa9, 0xd8, 0x14, 0x29, 0x6d, 0x4e, 0x9e, 0x49, 0x1d, + 0x11, 0x5e, 0x44, 0x5c, 0x30, 0xc5, 0xb4, 0x0a, 0x8d, 0x42, 0x3f, 0xcc, 0x69, 0x28, 0x78, 0x1a, + 0x12, 0x5e, 0x04, 0x67, 0xe0, 0xce, 0x49, 0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x39, 0x5b, 0x4b, 0x8a, + 0xfe, 0x00, 0x48, 0x45, 0x54, 0x25, 0x6f, 0x58, 0x46, 0x4d, 0x68, 0x27, 0xde, 0xdb, 0x41, 0xd7, + 0xbb, 0x2b, 0xb6, 0x0d, 0xf5, 0x7f, 0x5f, 0xa8, 0x37, 0x41, 0x07, 0xef, 0x78, 0x8b, 0xde, 0x79, + 0x47, 0xff, 0xdd, 0xa0, 0x13, 0xcf, 0xbc, 0x81, 0x8b, 0xb7, 0x00, 0x00, 0x00, 0xff, 0xff, 0x49, + 0xc3, 0x7d, 0x73, 0x53, 0x03, 0x00, 0x00, } diff --git a/service/gateway/api/proto/api.pb.stack.go b/service/stackway/api/proto/api.pb.stack.go similarity index 87% rename from service/gateway/api/proto/api.pb.stack.go rename to service/stackway/api/proto/api.pb.stack.go index f62475b..ebcd9c8 100644 --- a/service/gateway/api/proto/api.pb.stack.go +++ b/service/stackway/api/proto/api.pb.stack.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-stack. DO NOT EDIT. -// source: github.com/stack-labs/stack-rpc-plugins/service/gateway/api/proto/api.proto +// source: github.com/stack-labs/stack-rpc-plugins/service/stackway/api/proto/api.proto package stack_rpc_api diff --git a/service/gateway/api/proto/api.proto b/service/stackway/api/proto/api.proto similarity index 100% rename from service/gateway/api/proto/api.proto rename to service/stackway/api/proto/api.proto diff --git a/service/gateway/go.mod b/service/stackway/go.mod similarity index 85% rename from service/gateway/go.mod rename to service/stackway/go.mod index af482d0..4bb513d 100644 --- a/service/gateway/go.mod +++ b/service/stackway/go.mod @@ -1,4 +1,4 @@ -module github.com/stack-labs/stack-rpc-plugins/service/gateway +module github.com/stack-labs/stack-rpc-plugins/service/stackway go 1.14 diff --git a/service/gateway/go.sum b/service/stackway/go.sum similarity index 100% rename from service/gateway/go.sum rename to service/stackway/go.sum diff --git a/service/gateway/handler/meta.go b/service/stackway/handler/meta.go similarity index 100% rename from service/gateway/handler/meta.go rename to service/stackway/handler/meta.go diff --git a/service/gateway/handler/rpc.go b/service/stackway/handler/rpc.go similarity index 98% rename from service/gateway/handler/rpc.go rename to service/stackway/handler/rpc.go index 7da400d..4022711 100644 --- a/service/gateway/handler/rpc.go +++ b/service/stackway/handler/rpc.go @@ -11,7 +11,7 @@ import ( "github.com/stack-labs/stack-rpc/client" "github.com/stack-labs/stack-rpc/errors" - "github.com/stack-labs/stack-rpc-plugins/service/gateway/helper" + "github.com/stack-labs/stack-rpc-plugins/service/stackway/helper" ) type rpcRequest struct { diff --git a/service/gateway/handler/rpc_test.go b/service/stackway/handler/rpc_test.go similarity index 99% rename from service/gateway/handler/rpc_test.go rename to service/stackway/handler/rpc_test.go index c246680..b28ccbf 100644 --- a/service/gateway/handler/rpc_test.go +++ b/service/stackway/handler/rpc_test.go @@ -1,4 +1,4 @@ -// +build gitignore +// +build ignore package handler diff --git a/service/gateway/helper/helper.go b/service/stackway/helper/helper.go similarity index 100% rename from service/gateway/helper/helper.go rename to service/stackway/helper/helper.go diff --git a/service/gateway/helper/helper_test.go b/service/stackway/helper/helper_test.go similarity index 100% rename from service/gateway/helper/helper_test.go rename to service/stackway/helper/helper_test.go diff --git a/service/gateway/service.go b/service/stackway/hook/hook.go similarity index 74% rename from service/gateway/service.go rename to service/stackway/hook/hook.go index 01c34f8..e084db4 100644 --- a/service/gateway/service.go +++ b/service/stackway/hook/hook.go @@ -1,19 +1,20 @@ -package gateway +package hook import ( "github.com/stack-labs/stack-rpc" - "github.com/stack-labs/stack-rpc-plugins/service/gateway/api" - "github.com/stack-labs/stack-rpc-plugins/service/gateway/plugin" "github.com/stack-labs/stack-rpc/util/log" + + "github.com/stack-labs/stack-rpc-plugins/service/stackway/api" + "github.com/stack-labs/stack-rpc-plugins/service/stackway/plugin" ) func Hook(svc stack.Service) { apiServer := api.NewServer(svc) - // gateway options + // stackway options _ = svc.Init(api.Options()...) - // gateway hook + // stackway hook _ = svc.Init( stack.AfterStart(apiServer.Start), stack.AfterStop(apiServer.Stop), diff --git a/service/gateway/service_test.go b/service/stackway/hook/hook_test.go similarity index 95% rename from service/gateway/service_test.go rename to service/stackway/hook/hook_test.go index 24b75b6..f2d973f 100644 --- a/service/gateway/service_test.go +++ b/service/stackway/hook/hook_test.go @@ -1,4 +1,4 @@ -package gateway +package hook import ( "bytes" @@ -18,8 +18,8 @@ import ( "github.com/stack-labs/stack-rpc/registry/memory" "github.com/stretchr/testify/assert" - "github.com/stack-labs/stack-rpc-plugins/service/gateway/test/handler" - test "github.com/stack-labs/stack-rpc-plugins/service/gateway/test/proto" + "github.com/stack-labs/stack-rpc-plugins/service/stackway/test/handler" + test "github.com/stack-labs/stack-rpc-plugins/service/stackway/test/proto" ) func run(ctx context.Context, t *testing.T) { @@ -40,7 +40,7 @@ stack: registry: name: memory - gateway: + stackway: address: :8080 handler: "meta" resolver: "stack" @@ -97,7 +97,7 @@ stack: // run service go func() { - // gateway hook + // stackway hook Hook(svc) if err := svc.Run(); err != nil { diff --git a/service/gateway/cmd/main.go b/service/stackway/main.go similarity index 77% rename from service/gateway/cmd/main.go rename to service/stackway/main.go index f31fe23..4ceac11 100644 --- a/service/gateway/cmd/main.go +++ b/service/stackway/main.go @@ -4,13 +4,13 @@ import ( "github.com/stack-labs/stack-rpc" "github.com/stack-labs/stack-rpc/util/log" - "github.com/stack-labs/stack-rpc-plugins/service/gateway/api" + "github.com/stack-labs/stack-rpc-plugins/service/stackway/api" ) func main() { svc := stack.NewService() - // gateway server + // stackway server apiServer := api.NewServer(svc) svc.Init(apiServer.Options()...) diff --git a/service/gateway/plugin/README.md b/service/stackway/plugin/README.md similarity index 100% rename from service/gateway/plugin/README.md rename to service/stackway/plugin/README.md diff --git a/service/gateway/plugin/build/commands.go b/service/stackway/plugin/build/commands.go similarity index 95% rename from service/gateway/plugin/build/commands.go rename to service/stackway/plugin/build/commands.go index 3728598..237a4db 100644 --- a/service/gateway/plugin/build/commands.go +++ b/service/stackway/plugin/build/commands.go @@ -6,9 +6,10 @@ import ( "path/filepath" "strings" - "github.com/stack-labs/stack-rpc-plugins/service/gateway/plugin" "github.com/stack-labs/stack-rpc/pkg/cli" goplugin "github.com/stack-labs/stack-rpc/plugin" + + "github.com/stack-labs/stack-rpc-plugins/service/stackway/plugin" ) func build(ctx *cli.Context) { @@ -107,7 +108,7 @@ func Commands() []cli.Command { }} } -// returns a micro plugin which loads plugins +// returns a stack plugin which loads plugins func Flags() plugin.Plugin { return plugin.NewPlugin( plugin.WithName("plugin"), diff --git a/service/gateway/plugin/manager.go b/service/stackway/plugin/manager.go similarity index 100% rename from service/gateway/plugin/manager.go rename to service/stackway/plugin/manager.go diff --git a/service/gateway/plugin/options.go b/service/stackway/plugin/options.go similarity index 100% rename from service/gateway/plugin/options.go rename to service/stackway/plugin/options.go diff --git a/service/gateway/plugin/plugin.go b/service/stackway/plugin/plugin.go similarity index 100% rename from service/gateway/plugin/plugin.go rename to service/stackway/plugin/plugin.go diff --git a/service/gateway/server/options.go b/service/stackway/server/options.go similarity index 97% rename from service/gateway/server/options.go rename to service/stackway/server/options.go index 0600891..66b0d5c 100644 --- a/service/gateway/server/options.go +++ b/service/stackway/server/options.go @@ -12,7 +12,7 @@ import ( var ( DefaultAddress = ":8080" - DefaultName = "stack.rpc.gateway" + DefaultName = "stack.rpc.stackway" ) type hookServerKey struct{} diff --git a/service/gateway/server/server.go b/service/stackway/server/server.go similarity index 89% rename from service/gateway/server/server.go rename to service/stackway/server/server.go index 6b23f5a..363b583 100644 --- a/service/gateway/server/server.go +++ b/service/stackway/server/server.go @@ -17,7 +17,7 @@ import ( mnet "github.com/stack-labs/stack-rpc/util/net" ) -type gatewayServer struct { +type stackwayServer struct { sync.RWMutex running bool opts server.Options @@ -33,13 +33,13 @@ type gatewayServer struct { } var ( - _ server.Server = &gatewayServer{} + _ server.Server = &stackwayServer{} ) -func newServer(opts ...server.Option) *gatewayServer { +func newServer(opts ...server.Option) *stackwayServer { options := newOptions(opts...) - return &gatewayServer{ + return &stackwayServer{ opts: options, handlers: make(map[string]server.Handler), subscribers: make(map[string][]server.Subscriber), @@ -47,14 +47,14 @@ func newServer(opts ...server.Option) *gatewayServer { } } -func (s *gatewayServer) Options() server.Options { +func (s *stackwayServer) Options() server.Options { s.Lock() defer s.Unlock() return s.opts } -func (s *gatewayServer) Init(opts ...server.Option) error { +func (s *stackwayServer) Init(opts ...server.Option) error { s.Lock() defer s.Unlock() @@ -64,7 +64,7 @@ func (s *gatewayServer) Init(opts ...server.Option) error { return nil } -func (s *gatewayServer) Handle(h server.Handler) error { +func (s *stackwayServer) Handle(h server.Handler) error { s.Lock() defer s.Unlock() @@ -75,7 +75,7 @@ func (s *gatewayServer) Handle(h server.Handler) error { return nil } -func (s *gatewayServer) NewHandler(h interface{}, opts ...server.HandlerOption) server.Handler { +func (s *stackwayServer) NewHandler(h interface{}, opts ...server.HandlerOption) server.Handler { var options server.HandlerOptions for _, o := range opts { o(&options) @@ -88,7 +88,7 @@ func (s *gatewayServer) NewHandler(h interface{}, opts ...server.HandlerOption) } } -func (s *gatewayServer) NewSubscriber(topic string, fn interface{}, opts ...server.SubscriberOption) server.Subscriber { +func (s *stackwayServer) NewSubscriber(topic string, fn interface{}, opts ...server.SubscriberOption) server.Subscriber { var options server.SubscriberOptions for _, o := range opts { o(&options) @@ -101,7 +101,7 @@ func (s *gatewayServer) NewSubscriber(topic string, fn interface{}, opts ...serv } } -func (s *gatewayServer) Register() error { +func (s *stackwayServer) Register() error { var err error var advt, host, port string @@ -195,7 +195,7 @@ func (s *gatewayServer) Register() error { return nil } -func (s *gatewayServer) Deregister() error { +func (s *stackwayServer) Deregister() error { var err error var advt, host, port string @@ -259,7 +259,7 @@ func (s *gatewayServer) Deregister() error { return nil } -func (s *gatewayServer) Subscribe(sub server.Subscriber) error { +func (s *stackwayServer) Subscribe(sub server.Subscriber) error { s.Lock() defer s.Unlock() @@ -269,7 +269,7 @@ func (s *gatewayServer) Subscribe(sub server.Subscriber) error { return nil } -func (s *gatewayServer) Start() error { +func (s *stackwayServer) Start() error { s.RLock() if s.started { s.RUnlock() @@ -356,7 +356,7 @@ func (s *gatewayServer) Start() error { } // TODO graceful exit need supported by gateway's api server - // stop gateway server + // stop stackway server ch <- stopFn() // disconnect the broker @@ -371,7 +371,7 @@ func (s *gatewayServer) Start() error { return nil } -func (s *gatewayServer) Stop() error { +func (s *stackwayServer) Stop() error { s.RLock() if !s.started { s.RUnlock() @@ -390,8 +390,8 @@ func (s *gatewayServer) Stop() error { return err } -func (s *gatewayServer) String() string { - return "gateway" +func (s *stackwayServer) String() string { + return "stackway" } func NewServer(opts ...server.Option) server.Server { diff --git a/service/gateway/conf/stack_config.yml b/service/stackway/stack_config.yml similarity index 83% rename from service/gateway/conf/stack_config.yml rename to service/stackway/stack_config.yml index be9eb61..834d630 100644 --- a/service/gateway/conf/stack_config.yml +++ b/service/stackway/stack_config.yml @@ -1,13 +1,13 @@ stack: server: - name: "stack.rpc.gateway" + name: "stack.rpc.stackway" version: "1.0.0" - address: :8080 # gateway run as server address + address: :8080 # stackway run as server address registry: name: mdns - gateway: + stackway: handler: "meta" resolver: "stack" rpc_path: "/rpc" diff --git a/service/gateway/test/handler/handler.go b/service/stackway/test/handler/handler.go similarity index 86% rename from service/gateway/test/handler/handler.go rename to service/stackway/test/handler/handler.go index 2f76347..8b4a62e 100644 --- a/service/gateway/test/handler/handler.go +++ b/service/stackway/test/handler/handler.go @@ -3,8 +3,9 @@ package handler import ( "context" - test "github.com/stack-labs/stack-rpc-plugins/service/gateway/test/proto" proto "github.com/stack-labs/stack-rpc/api/proto" + + test "github.com/stack-labs/stack-rpc-plugins/service/stackway/test/proto" ) var _ test.TestHandler = &Handler{} diff --git a/service/gateway/test/proto/test.pb.go b/service/stackway/test/proto/test.pb.go similarity index 59% rename from service/gateway/test/proto/test.pb.go rename to service/stackway/test/proto/test.pb.go index 0401609..7ad846a 100644 --- a/service/gateway/test/proto/test.pb.go +++ b/service/stackway/test/proto/test.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: test.proto +// source: github.com/stack-labs/stack-rpc-plugins/service/stackway/test/proto/test.proto -package stack_rpc_gateway_test +package stack_rpc_stackway_test import ( fmt "fmt" @@ -32,7 +32,7 @@ func (m *Request) Reset() { *m = Request{} } func (m *Request) String() string { return proto.CompactTextString(m) } func (*Request) ProtoMessage() {} func (*Request) Descriptor() ([]byte, []int) { - return fileDescriptor_c161fcfdc0c3ff1e, []int{0} + return fileDescriptor_cc0c9e6e8b9a187f, []int{0} } func (m *Request) XXX_Unmarshal(b []byte) error { @@ -71,7 +71,7 @@ func (m *Response) Reset() { *m = Response{} } func (m *Response) String() string { return proto.CompactTextString(m) } func (*Response) ProtoMessage() {} func (*Response) Descriptor() ([]byte, []int) { - return fileDescriptor_c161fcfdc0c3ff1e, []int{1} + return fileDescriptor_cc0c9e6e8b9a187f, []int{1} } func (m *Response) XXX_Unmarshal(b []byte) error { @@ -100,24 +100,28 @@ func (m *Response) GetMsg() string { } func init() { - proto.RegisterType((*Request)(nil), "stack.rpc.gateway.test.Request") - proto.RegisterType((*Response)(nil), "stack.rpc.gateway.test.Response") -} - -func init() { proto.RegisterFile("test.proto", fileDescriptor_c161fcfdc0c3ff1e) } - -var fileDescriptor_c161fcfdc0c3ff1e = []byte{ - // 192 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2a, 0x49, 0x2d, 0x2e, - 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2b, 0x2e, 0x49, 0x4c, 0xce, 0xd6, 0x2b, 0x2a, - 0x48, 0xd6, 0x4b, 0x4f, 0x2c, 0x49, 0x2d, 0x4f, 0xac, 0xd4, 0x03, 0xc9, 0x4a, 0x19, 0xa7, 0x67, - 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, 0x95, 0xe8, 0xe6, 0x24, 0x26, 0x15, - 0x43, 0x99, 0x45, 0x05, 0xc9, 0xfa, 0x89, 0x05, 0x99, 0xfa, 0x60, 0x23, 0x40, 0x2c, 0x88, 0x61, - 0x4a, 0xd2, 0x5c, 0xec, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x42, 0x02, 0x5c, 0xcc, 0xb9, - 0xc5, 0xe9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x20, 0xa6, 0x92, 0x0c, 0x17, 0x47, 0x50, - 0x6a, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0x2a, 0xa6, 0xac, 0x51, 0x1d, 0x17, 0x4b, 0x08, 0x48, 0x9f, - 0x17, 0x17, 0x73, 0x50, 0x41, 0xb2, 0x90, 0xbc, 0x1e, 0x76, 0x77, 0xe9, 0x41, 0xcd, 0x97, 0x52, - 0xc0, 0xad, 0x00, 0x62, 0x87, 0x12, 0x83, 0x90, 0x16, 0x17, 0xb3, 0x63, 0x41, 0xa6, 0x10, 0xbf, - 0x5e, 0x7a, 0xbe, 0x1e, 0xc8, 0x91, 0x30, 0xbd, 0x02, 0x08, 0x01, 0x98, 0xda, 0x24, 0x36, 0xb0, - 0x0f, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x80, 0xde, 0x77, 0xb6, 0x1c, 0x01, 0x00, 0x00, + proto.RegisterType((*Request)(nil), "stack.rpc.stackway.test.Request") + proto.RegisterType((*Response)(nil), "stack.rpc.stackway.test.Response") +} + +func init() { + proto.RegisterFile("github.com/stack-labs/stack-rpc-plugins/service/stackway/test/proto/test.proto", fileDescriptor_cc0c9e6e8b9a187f) +} + +var fileDescriptor_cc0c9e6e8b9a187f = []byte{ + // 214 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x8f, 0xbf, 0x4a, 0xc0, 0x30, + 0x10, 0xc6, 0x2d, 0x15, 0xff, 0x64, 0x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, 0xff, 0x3e, 0xa8, + 0x48, 0x38, 0x64, 0x01, 0x00, 0x00, } diff --git a/service/gateway/test/proto/test.pb.stack.go b/service/stackway/test/proto/test.pb.stack.go similarity index 96% rename from service/gateway/test/proto/test.pb.stack.go rename to service/stackway/test/proto/test.pb.stack.go index 0da0903..0a0c2f3 100644 --- a/service/gateway/test/proto/test.pb.stack.go +++ b/service/stackway/test/proto/test.pb.stack.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-stack. DO NOT EDIT. -// source: test.proto +// source: github.com/stack-labs/stack-rpc-plugins/service/stackway/test/proto/test.proto -package stack_rpc_gateway_test +package stack_rpc_stackway_test import ( fmt "fmt" diff --git a/service/gateway/test/proto/test.proto b/service/stackway/test/proto/test.proto similarity index 91% rename from service/gateway/test/proto/test.proto rename to service/stackway/test/proto/test.proto index 597aade..33a12bc 100644 --- a/service/gateway/test/proto/test.proto +++ b/service/stackway/test/proto/test.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package stack.rpc.gateway.test; +package stack.rpc.stackway.test; import "github.com/stack-labs/stack-rpc/api/proto/api.proto"; From e66c16097172d06ee9e8da6f90bd31334a01fcc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B4=AA=E6=B3=A2?= Date: Sun, 13 Dec 2020 01:00:18 +0800 Subject: [PATCH 2/2] fix error with stack rpc v1.0.0 --- service/stackway/go.mod | 2 +- service/stackway/go.sum | 5 +++-- service/stackway/handler/meta.go | 2 +- service/stackway/handler/rpc.go | 2 +- service/stackway/handler/rpc_test.go | 2 +- service/stackway/helper/helper.go | 2 +- service/stackway/helper/helper_test.go | 2 +- service/stackway/server/options.go | 12 ++++++------ service/stackway/server/server.go | 2 +- 9 files changed, 16 insertions(+), 15 deletions(-) diff --git a/service/stackway/go.mod b/service/stackway/go.mod index 4bb513d..d31d137 100644 --- a/service/stackway/go.mod +++ b/service/stackway/go.mod @@ -4,7 +4,7 @@ go 1.14 replace ( github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.4 - github.com/stack-labs/stack-rpc v1.0.0 => ../../../stack-rpc + github.com/stack-labs/stack-rpc v0.0.0 => ../../../stack-rpc google.golang.org/grpc => google.golang.org/grpc v1.26.0 ) diff --git a/service/stackway/go.sum b/service/stackway/go.sum index d093557..2aafbd0 100644 --- a/service/stackway/go.sum +++ b/service/stackway/go.sum @@ -418,8 +418,8 @@ github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI= -github.com/stack-labs/stack-rpc v1.0.0-rc2 h1:6cD5j9Hp1tqMXF7rnvjoPfiq2ILu6K5L6WIo+luUqB8= -github.com/stack-labs/stack-rpc v1.0.0-rc2/go.mod h1:Wyvz2jT9SbryJ1tfDNV86wXMEGOi+xF2zlXXnBW1f2A= +github.com/stack-labs/stack-rpc v1.0.0 h1:YGg7H+iwaVEKyu82xH/H8/ywOSiDNEJ9Sg9IdeOdtsM= +github.com/stack-labs/stack-rpc v1.0.0/go.mod h1:Am8wYA4vCnpq5qkhNon1xlcmdAUUIxWRJ2DJTQbes7I= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= @@ -446,6 +446,7 @@ github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf github.com/xeipuuv/gojsonschema v1.1.0/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xlab/treeprint v1.0.0/go.mod h1:IoImgRak9i3zJyuxOKUP1v4UZd1tMoKkq/Cimt1uhCg= go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg= go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0= diff --git a/service/stackway/handler/meta.go b/service/stackway/handler/meta.go index 77aa636..3221d34 100644 --- a/service/stackway/handler/meta.go +++ b/service/stackway/handler/meta.go @@ -7,7 +7,7 @@ import ( "github.com/stack-labs/stack-rpc/api/handler" "github.com/stack-labs/stack-rpc/api/handler/event" "github.com/stack-labs/stack-rpc/api/router" - "github.com/stack-labs/stack-rpc/errors" + "github.com/stack-labs/stack-rpc/util/errors" // TODO: only import handler package aapi "github.com/stack-labs/stack-rpc/api/handler/api" diff --git a/service/stackway/handler/rpc.go b/service/stackway/handler/rpc.go index 4022711..9f75be9 100644 --- a/service/stackway/handler/rpc.go +++ b/service/stackway/handler/rpc.go @@ -9,7 +9,7 @@ import ( "github.com/stack-labs/stack-rpc" "github.com/stack-labs/stack-rpc/client" - "github.com/stack-labs/stack-rpc/errors" + "github.com/stack-labs/stack-rpc/util/errors" "github.com/stack-labs/stack-rpc-plugins/service/stackway/helper" ) diff --git a/service/stackway/handler/rpc_test.go b/service/stackway/handler/rpc_test.go index b28ccbf..d8216c3 100644 --- a/service/stackway/handler/rpc_test.go +++ b/service/stackway/handler/rpc_test.go @@ -14,7 +14,7 @@ import ( "github.com/stack-labs/stack-rpc/client" "github.com/stack-labs/stack-rpc/client/selector" "github.com/stack-labs/stack-rpc/cmd" - "github.com/stack-labs/stack-rpc/metadata" + "github.com/stack-labs/stack-rpc/pkg/metadata" "github.com/stack-labs/stack-rpc/registry/memory" "github.com/stack-labs/stack-rpc/server" ) diff --git a/service/stackway/helper/helper.go b/service/stackway/helper/helper.go index e257fb9..b5d38fc 100644 --- a/service/stackway/helper/helper.go +++ b/service/stackway/helper/helper.go @@ -9,7 +9,7 @@ import ( "net/http" "strings" - "github.com/stack-labs/stack-rpc/metadata" + "github.com/stack-labs/stack-rpc/pkg/metadata" ) type TLS struct { diff --git a/service/stackway/helper/helper_test.go b/service/stackway/helper/helper_test.go index 066f256..d73bbd9 100644 --- a/service/stackway/helper/helper_test.go +++ b/service/stackway/helper/helper_test.go @@ -4,7 +4,7 @@ import ( "net/http" "testing" - "github.com/stack-labs/stack-rpc/metadata" + "github.com/stack-labs/stack-rpc/pkg/metadata" ) func TestRequestToContext(t *testing.T) { diff --git a/service/stackway/server/options.go b/service/stackway/server/options.go index 66b0d5c..3bbb555 100644 --- a/service/stackway/server/options.go +++ b/service/stackway/server/options.go @@ -3,11 +3,11 @@ package server import ( "context" - "github.com/stack-labs/stack-rpc/broker" + "github.com/stack-labs/stack-rpc/broker/http" "github.com/stack-labs/stack-rpc/codec" - "github.com/stack-labs/stack-rpc/registry" + "github.com/stack-labs/stack-rpc/registry/mdns" "github.com/stack-labs/stack-rpc/server" - "github.com/stack-labs/stack-rpc/transport" + httpt "github.com/stack-labs/stack-rpc/transport/http" ) var ( @@ -44,15 +44,15 @@ func newOptions(opt ...server.Option) server.Options { } if opts.Broker == nil { - opts.Broker = broker.DefaultBroker + opts.Broker = http.NewBroker() } if opts.Registry == nil { - opts.Registry = registry.DefaultRegistry + opts.Registry = mdns.NewRegistry() } if opts.Transport == nil { - opts.Transport = transport.DefaultTransport + opts.Transport = httpt.NewTransport() } if opts.RegisterCheck == nil { diff --git a/service/stackway/server/server.go b/service/stackway/server/server.go index 363b583..9bbeeab 100644 --- a/service/stackway/server/server.go +++ b/service/stackway/server/server.go @@ -8,7 +8,7 @@ import ( "time" "github.com/google/uuid" - "github.com/stack-labs/stack-rpc/metadata" + "github.com/stack-labs/stack-rpc/pkg/metadata" "github.com/stack-labs/stack-rpc/registry" "github.com/stack-labs/stack-rpc/server" "github.com/stack-labs/stack-rpc/server/mock"