-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from hb-chen/master
rename gateway
- Loading branch information
Showing
37 changed files
with
214 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
66 changes: 33 additions & 33 deletions
66
service/gateway/api/proto/api.pb.go → service/stackway/api/proto/api.pb.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
service/gateway/api/proto/api.pb.stack.go → service/stackway/api/proto/api.pb.stack.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.