From 1a5c5b7cb6a482af77533f1b28e87ce412d94bda Mon Sep 17 00:00:00 2001 From: Liujian <824010343@qq.com> Date: Sat, 14 Aug 2021 00:17:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=93=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/goku-eosc/inner.go | 60 ------------------- app/{goku-eosc => goku}/.gitignore | 0 app/{goku-eosc => goku}/flag.go | 0 app/goku/inner.go | 60 +++++++++++++++++++ app/{goku-eosc => goku}/main.go | 2 +- app/{goku-eosc => goku}/plugin.go | 0 app/{goku-eosc => goku}/profession.go | 0 app/{goku-eosc => goku}/profession.yml | 0 app/{goku-eosc => goku}/store.go | 0 app/{goku-eosc => goku}/yaml-demo/auth.yml | 0 .../yaml-demo/discovery.yml | 0 app/{goku-eosc => goku}/yaml-demo/service.yml | 0 .../yaml-demo/upstream.yml | 0 auth/aksk/aksk.go | 4 +- auth/aksk/aksk_test.go | 3 +- auth/aksk/util.go | 4 +- auth/apikey/apikey.go | 4 +- auth/apikey/apikey_test.go | 7 ++- auth/auth.go | 4 +- auth/basic/basic.go | 4 +- auth/basic/basic_test.go | 4 +- auth/jwt/jwt.go | 4 +- auth/jwt/jwt_test.go | 3 +- auth/jwt/verify.go | 2 +- discovery/consul/clients.go | 2 +- discovery/consul/consul.go | 2 +- discovery/consul/consul_test.go | 2 +- discovery/consul/driver.go | 2 +- discovery/discovery.go | 2 +- discovery/eureka/client.go | 2 +- discovery/eureka/driver.go | 2 +- discovery/eureka/eureka.go | 2 +- discovery/eureka/eureka_test.go | 2 +- discovery/nacos/client.go | 2 +- discovery/nacos/driver.go | 2 +- discovery/nacos/nacos.go | 2 +- discovery/nacos/nacos_test.go | 2 +- discovery/static/static.go | 4 +- go.mod | 2 +- health-check-http/agent.go | 2 +- health-check-http/http-check.go | 2 +- node/http-context/context.go | 2 +- node/http-proxy/request.go | 2 +- node/http-proxy/response.go | 2 +- router/create.go | 3 +- router/create_test.go | 2 +- router/http-router/config.go | 6 +- router/http-router/driver.go | 35 +++++------ router/http-router/router.go | 4 +- router/router-http/config.go | 6 +- router/router-http/endpoint.go | 6 +- router/router-http/match.go | 6 +- router/router-http/parse.go | 6 +- router/router-http/router.go | 2 +- router/router.go | 51 ++++++++-------- service/service-http/config.go | 4 +- service/service-http/service.go | 14 ++--- service/service-http/service_test.go | 10 ++-- service/service.go | 8 +-- upstream/balance/balance.go | 2 +- upstream/round-robin/round_robin.go | 4 +- upstream/round-robin/round_robin_test.go | 2 +- upstream/upstream-http/config.go | 2 +- upstream/upstream-http/driver.go | 2 +- upstream/upstream-http/upstream.go | 14 ++--- upstream/upstream-http/upstream_test.go | 6 +- upstream/upstream-http_anonymous/org.go | 8 +-- upstream/upstream.go | 6 +- upstream/upstream_test.go | 2 +- 69 files changed, 210 insertions(+), 208 deletions(-) delete mode 100644 app/goku-eosc/inner.go rename app/{goku-eosc => goku}/.gitignore (100%) rename app/{goku-eosc => goku}/flag.go (100%) create mode 100644 app/goku/inner.go rename app/{goku-eosc => goku}/main.go (97%) rename app/{goku-eosc => goku}/plugin.go (100%) rename app/{goku-eosc => goku}/profession.go (100%) rename app/{goku-eosc => goku}/profession.yml (100%) rename app/{goku-eosc => goku}/store.go (100%) rename app/{goku-eosc => goku}/yaml-demo/auth.yml (100%) rename app/{goku-eosc => goku}/yaml-demo/discovery.yml (100%) rename app/{goku-eosc => goku}/yaml-demo/service.yml (100%) rename app/{goku-eosc => goku}/yaml-demo/upstream.yml (100%) diff --git a/app/goku-eosc/inner.go b/app/goku-eosc/inner.go deleted file mode 100644 index 8071d804..00000000 --- a/app/goku-eosc/inner.go +++ /dev/null @@ -1,60 +0,0 @@ -package main - -import ( - "github.com/eolinker/goku-eosc/auth/aksk" - "github.com/eolinker/goku-eosc/auth/apikey" - "github.com/eolinker/goku-eosc/auth/basic" - "github.com/eolinker/goku-eosc/auth/jwt" - "github.com/eolinker/goku-eosc/discovery/consul" - "github.com/eolinker/goku-eosc/discovery/eureka" - "github.com/eolinker/goku-eosc/discovery/nacos" - "github.com/eolinker/goku-eosc/discovery/static" - http_router "github.com/eolinker/goku-eosc/router/http-router" - service_http "github.com/eolinker/goku-eosc/service/service-http" - store_memory "github.com/eolinker/goku-eosc/store-memory" - upstream_http "github.com/eolinker/goku-eosc/upstream/upstream-http" -) - -func Register() { - storeRegister() - - routerRegister() - - serviceRegister() - - upstreamRegister() - - discoveryRegister() - - authRegister() -} - -func authRegister() { - basic.Register() - apikey.Register() - aksk.Register() - jwt.Register() -} - -func discoveryRegister() { - consul.Register() - eureka.Register() - nacos.Register() - static.Register() -} - -func storeRegister() { - store_memory.Register() -} - -func upstreamRegister() { - upstream_http.Register() -} - -func serviceRegister() { - service_http.Register() -} - -func routerRegister() { - http_router.Register() -} diff --git a/app/goku-eosc/.gitignore b/app/goku/.gitignore similarity index 100% rename from app/goku-eosc/.gitignore rename to app/goku/.gitignore diff --git a/app/goku-eosc/flag.go b/app/goku/flag.go similarity index 100% rename from app/goku-eosc/flag.go rename to app/goku/flag.go diff --git a/app/goku/inner.go b/app/goku/inner.go new file mode 100644 index 00000000..2ed11b9c --- /dev/null +++ b/app/goku/inner.go @@ -0,0 +1,60 @@ +package main + +import ( + "github.com/eolinker/goku/auth/aksk" + "github.com/eolinker/goku/auth/apikey" + "github.com/eolinker/goku/auth/basic" + "github.com/eolinker/goku/auth/jwt" + "github.com/eolinker/goku/discovery/consul" + "github.com/eolinker/goku/discovery/eureka" + "github.com/eolinker/goku/discovery/nacos" + "github.com/eolinker/goku/discovery/static" + http_router "github.com/eolinker/goku/router/http-router" + service_http "github.com/eolinker/goku/service/service-http" + store_memory "github.com/eolinker/goku/store-memory" + upstream_http "github.com/eolinker/goku/upstream/upstream-http" +) + +func Register() { + storeRegister() + + routerRegister() + + serviceRegister() + + upstreamRegister() + + discoveryRegister() + + authRegister() +} + +func authRegister() { + basic.Register() + apikey.Register() + aksk.Register() + jwt.Register() +} + +func discoveryRegister() { + consul.Register() + eureka.Register() + nacos.Register() + static.Register() +} + +func storeRegister() { + store_memory.Register() +} + +func upstreamRegister() { + upstream_http.Register() +} + +func serviceRegister() { + service_http.Register() +} + +func routerRegister() { + http_router.Register() +} diff --git a/app/goku-eosc/main.go b/app/goku/main.go similarity index 97% rename from app/goku-eosc/main.go rename to app/goku/main.go index a12de7e1..1dc94aa6 100644 --- a/app/goku-eosc/main.go +++ b/app/goku/main.go @@ -6,7 +6,7 @@ import ( "path/filepath" "runtime" - reader_yaml "github.com/eolinker/goku-eosc/reader-yaml" + reader_yaml "github.com/eolinker/goku/reader-yaml" _ "net/http/pprof" diff --git a/app/goku-eosc/plugin.go b/app/goku/plugin.go similarity index 100% rename from app/goku-eosc/plugin.go rename to app/goku/plugin.go diff --git a/app/goku-eosc/profession.go b/app/goku/profession.go similarity index 100% rename from app/goku-eosc/profession.go rename to app/goku/profession.go diff --git a/app/goku-eosc/profession.yml b/app/goku/profession.yml similarity index 100% rename from app/goku-eosc/profession.yml rename to app/goku/profession.yml diff --git a/app/goku-eosc/store.go b/app/goku/store.go similarity index 100% rename from app/goku-eosc/store.go rename to app/goku/store.go diff --git a/app/goku-eosc/yaml-demo/auth.yml b/app/goku/yaml-demo/auth.yml similarity index 100% rename from app/goku-eosc/yaml-demo/auth.yml rename to app/goku/yaml-demo/auth.yml diff --git a/app/goku-eosc/yaml-demo/discovery.yml b/app/goku/yaml-demo/discovery.yml similarity index 100% rename from app/goku-eosc/yaml-demo/discovery.yml rename to app/goku/yaml-demo/discovery.yml diff --git a/app/goku-eosc/yaml-demo/service.yml b/app/goku/yaml-demo/service.yml similarity index 100% rename from app/goku-eosc/yaml-demo/service.yml rename to app/goku/yaml-demo/service.yml diff --git a/app/goku-eosc/yaml-demo/upstream.yml b/app/goku/yaml-demo/upstream.yml similarity index 100% rename from app/goku-eosc/yaml-demo/upstream.yml rename to app/goku/yaml-demo/upstream.yml diff --git a/auth/aksk/aksk.go b/auth/aksk/aksk.go index 11ff2692..6d7c34d3 100644 --- a/auth/aksk/aksk.go +++ b/auth/aksk/aksk.go @@ -6,8 +6,8 @@ import ( "time" "github.com/eolinker/eosc" - "github.com/eolinker/goku-eosc/auth" - http_context "github.com/eolinker/goku-eosc/node/http-context" + "github.com/eolinker/goku/auth" + http_context "github.com/eolinker/goku/node/http-context" ) //supportTypes 当前驱动支持的authorization type值 diff --git a/auth/aksk/aksk_test.go b/auth/aksk/aksk_test.go index e069c5fe..c2d6c075 100644 --- a/auth/aksk/aksk_test.go +++ b/auth/aksk/aksk_test.go @@ -1,10 +1,11 @@ package aksk import ( - http_context "github.com/eolinker/goku-eosc/node/http-context" "io" "net/http" "testing" + + http_context "github.com/eolinker/goku/node/http-context" ) var akskConfig = []AKSKConfig{{ diff --git a/auth/aksk/util.go b/auth/aksk/util.go index 702d11e2..d34f925a 100644 --- a/auth/aksk/util.go +++ b/auth/aksk/util.go @@ -8,8 +8,8 @@ import ( "fmt" "strings" - "github.com/eolinker/goku-eosc/auth" - http_context "github.com/eolinker/goku-eosc/node/http-context" + "github.com/eolinker/goku/auth" + http_context "github.com/eolinker/goku/node/http-context" ) const dateHeader = "x-gateway-date" diff --git a/auth/apikey/apikey.go b/auth/apikey/apikey.go index aa790478..7f9d44dc 100644 --- a/auth/apikey/apikey.go +++ b/auth/apikey/apikey.go @@ -9,8 +9,8 @@ import ( "time" "github.com/eolinker/eosc" - "github.com/eolinker/goku-eosc/auth" - http_context "github.com/eolinker/goku-eosc/node/http-context" + "github.com/eolinker/goku/auth" + http_context "github.com/eolinker/goku/node/http-context" ) //supportTypes 当前驱动支持的authorization type值 diff --git a/auth/apikey/apikey_test.go b/auth/apikey/apikey_test.go index 5f318b71..db8fe12c 100644 --- a/auth/apikey/apikey_test.go +++ b/auth/apikey/apikey_test.go @@ -3,15 +3,16 @@ package apikey import ( "bytes" "encoding/json" - "github.com/eolinker/goku-eosc/auth" - http_context "github.com/eolinker/goku-eosc/node/http-context" + "errors" "mime/multipart" "net/http" "net/url" "strings" "testing" + + "github.com/eolinker/goku/auth" + http_context "github.com/eolinker/goku/node/http-context" ) -import "errors" var ( users = []User{ diff --git a/auth/auth.go b/auth/auth.go index 5b883244..819a503c 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -4,7 +4,7 @@ import ( "errors" "strings" - http_context "github.com/eolinker/goku-eosc/node/http-context" + http_context "github.com/eolinker/goku/node/http-context" ) const ( @@ -27,7 +27,7 @@ var ( //CheckSkill 检查能力 func CheckSkill(skill string) bool { - return skill == "github.com/eolinker/goku-eosc/auth.auth.IAuth" + return skill == "github.com/eolinker/goku/auth.auth.IAuth" } //IAuth 鉴权接口声明 diff --git a/auth/basic/basic.go b/auth/basic/basic.go index ab13f68e..41543b26 100644 --- a/auth/basic/basic.go +++ b/auth/basic/basic.go @@ -9,8 +9,8 @@ import ( "github.com/eolinker/eosc" - "github.com/eolinker/goku-eosc/auth" - http_context "github.com/eolinker/goku-eosc/node/http-context" + "github.com/eolinker/goku/auth" + http_context "github.com/eolinker/goku/node/http-context" ) //supportTypes 当前驱动支持的authorization type值 diff --git a/auth/basic/basic_test.go b/auth/basic/basic_test.go index 5673c317..1848a677 100644 --- a/auth/basic/basic_test.go +++ b/auth/basic/basic_test.go @@ -6,9 +6,9 @@ import ( "strings" "testing" - "github.com/eolinker/goku-eosc/auth" + "github.com/eolinker/goku/auth" - http_context "github.com/eolinker/goku-eosc/node/http-context" + http_context "github.com/eolinker/goku/node/http-context" ) var ( diff --git a/auth/jwt/jwt.go b/auth/jwt/jwt.go index e4d94e81..4a65519c 100644 --- a/auth/jwt/jwt.go +++ b/auth/jwt/jwt.go @@ -4,8 +4,8 @@ import ( "fmt" "github.com/eolinker/eosc" - "github.com/eolinker/goku-eosc/auth" - http_context "github.com/eolinker/goku-eosc/node/http-context" + "github.com/eolinker/goku/auth" + http_context "github.com/eolinker/goku/node/http-context" ) //supportTypes 当前驱动支持的authorization type值 diff --git a/auth/jwt/jwt_test.go b/auth/jwt/jwt_test.go index 30906bd6..5d7735e0 100644 --- a/auth/jwt/jwt_test.go +++ b/auth/jwt/jwt_test.go @@ -1,10 +1,11 @@ package jwt import ( - http_context "github.com/eolinker/goku-eosc/node/http-context" "io" "net/http" "testing" + + http_context "github.com/eolinker/goku/node/http-context" ) type responseWriter struct{} diff --git a/auth/jwt/verify.go b/auth/jwt/verify.go index 55473b2b..accecc35 100644 --- a/auth/jwt/verify.go +++ b/auth/jwt/verify.go @@ -16,7 +16,7 @@ import ( "strings" "time" - http_context "github.com/eolinker/goku-eosc/node/http-context" + http_context "github.com/eolinker/goku/node/http-context" ) type jwtToken struct { diff --git a/discovery/consul/clients.go b/discovery/consul/clients.go index 2800afb8..073acbc8 100644 --- a/discovery/consul/clients.go +++ b/discovery/consul/clients.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/eolinker/eosc/log" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" "github.com/hashicorp/consul/api" ) diff --git a/discovery/consul/consul.go b/discovery/consul/consul.go index b1cd1a1b..7b335133 100644 --- a/discovery/consul/consul.go +++ b/discovery/consul/consul.go @@ -9,7 +9,7 @@ import ( "github.com/eolinker/eosc" "github.com/eolinker/eosc/log" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" ) type consul struct { diff --git a/discovery/consul/consul_test.go b/discovery/consul/consul_test.go index 4bdbc6a3..dab7c8dd 100644 --- a/discovery/consul/consul_test.go +++ b/discovery/consul/consul_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" ) func TestConsulGetNodes(t *testing.T) { diff --git a/discovery/consul/driver.go b/discovery/consul/driver.go index 7fed1330..1c72ce9d 100644 --- a/discovery/consul/driver.go +++ b/discovery/consul/driver.go @@ -5,7 +5,7 @@ import ( "reflect" "sync" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" "github.com/eolinker/eosc" ) diff --git a/discovery/discovery.go b/discovery/discovery.go index 710d521f..9556b155 100644 --- a/discovery/discovery.go +++ b/discovery/discovery.go @@ -8,7 +8,7 @@ var ( //CheckSkill 检查目标技能是否符合 func CheckSkill(skill string) bool { - return skill == "github.com/eolinker/goku-eosc/discovery.discovery.IDiscovery" + return skill == "github.com/eolinker/goku/discovery.discovery.IDiscovery" } //IDiscovery 服务发现接口 diff --git a/discovery/eureka/client.go b/discovery/eureka/client.go index aba890c1..bd12895f 100644 --- a/discovery/eureka/client.go +++ b/discovery/eureka/client.go @@ -8,7 +8,7 @@ import ( "net/url" "github.com/eolinker/eosc/log" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" ) type client struct { diff --git a/discovery/eureka/driver.go b/discovery/eureka/driver.go index a98e1555..6e1125a2 100644 --- a/discovery/eureka/driver.go +++ b/discovery/eureka/driver.go @@ -6,7 +6,7 @@ import ( "sync" "github.com/eolinker/eosc" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" ) const ( diff --git a/discovery/eureka/eureka.go b/discovery/eureka/eureka.go index 63bf3db7..506062ac 100644 --- a/discovery/eureka/eureka.go +++ b/discovery/eureka/eureka.go @@ -9,7 +9,7 @@ import ( "github.com/eolinker/eosc/log" "github.com/eolinker/eosc" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" ) type eureka struct { diff --git a/discovery/eureka/eureka_test.go b/discovery/eureka/eureka_test.go index 110ca7ab..47303bbb 100644 --- a/discovery/eureka/eureka_test.go +++ b/discovery/eureka/eureka_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" ) func TestGetApp(t *testing.T) { diff --git a/discovery/nacos/client.go b/discovery/nacos/client.go index 46140a0b..ae393f01 100644 --- a/discovery/nacos/client.go +++ b/discovery/nacos/client.go @@ -11,7 +11,7 @@ import ( "github.com/eolinker/eosc/log" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" ) type client struct { diff --git a/discovery/nacos/driver.go b/discovery/nacos/driver.go index a4966018..dd99670a 100644 --- a/discovery/nacos/driver.go +++ b/discovery/nacos/driver.go @@ -6,7 +6,7 @@ import ( "sync" "github.com/eolinker/eosc" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" ) const ( diff --git a/discovery/nacos/nacos.go b/discovery/nacos/nacos.go index dd575108..7d66229b 100644 --- a/discovery/nacos/nacos.go +++ b/discovery/nacos/nacos.go @@ -9,7 +9,7 @@ import ( "github.com/eolinker/eosc/log" "github.com/eolinker/eosc" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" ) const ( diff --git a/discovery/nacos/nacos_test.go b/discovery/nacos/nacos_test.go index d04ad342..80c388f3 100644 --- a/discovery/nacos/nacos_test.go +++ b/discovery/nacos/nacos_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" ) func TestGetApp(t *testing.T) { diff --git a/discovery/static/static.go b/discovery/static/static.go index 25b3d919..1c305cad 100644 --- a/discovery/static/static.go +++ b/discovery/static/static.go @@ -10,10 +10,10 @@ import ( "time" "unicode" - health_check_http "github.com/eolinker/goku-eosc/health-check-http" + health_check_http "github.com/eolinker/goku/health-check-http" "github.com/eolinker/eosc" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" ) const name = "static" diff --git a/go.mod b/go.mod index fd5dd1f0..23befcf2 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/eolinker/goku-eosc +module github.com/eolinker/goku go 1.15 diff --git a/health-check-http/agent.go b/health-check-http/agent.go index 69dd4be6..e059d9a7 100644 --- a/health-check-http/agent.go +++ b/health-check-http/agent.go @@ -1,6 +1,6 @@ package health_check_http -import "github.com/eolinker/goku-eosc/discovery" +import "github.com/eolinker/goku/discovery" //agent 从属于HTTPCheck,实现了IHealthChecker接口 type agent struct { diff --git a/health-check-http/http-check.go b/health-check-http/http-check.go index 3ec82fb7..691aa8cd 100644 --- a/health-check-http/http-check.go +++ b/health-check-http/http-check.go @@ -10,7 +10,7 @@ import ( "github.com/eolinker/eosc/log" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" "github.com/go-basic/uuid" ) diff --git a/node/http-context/context.go b/node/http-context/context.go index ac95c076..cfcc1da0 100644 --- a/node/http-context/context.go +++ b/node/http-context/context.go @@ -5,7 +5,7 @@ import ( "github.com/valyala/fasthttp" - access_field "github.com/eolinker/goku-eosc/node/common/access-field" + access_field "github.com/eolinker/goku/node/common/access-field" uuid "github.com/satori/go.uuid" ) diff --git a/node/http-proxy/request.go b/node/http-proxy/request.go index 20c54a06..2714bcd1 100644 --- a/node/http-proxy/request.go +++ b/node/http-proxy/request.go @@ -5,7 +5,7 @@ import ( "github.com/valyala/fasthttp" - http_proxy_request "github.com/eolinker/goku-eosc/node/http-proxy/http-proxy-request" + http_proxy_request "github.com/eolinker/goku/node/http-proxy/http-proxy-request" ) //DoRequest 构造请求 diff --git a/node/http-proxy/response.go b/node/http-proxy/response.go index fb4bc372..0ddf9a74 100644 --- a/node/http-proxy/response.go +++ b/node/http-proxy/response.go @@ -6,7 +6,7 @@ import ( "net/http" "strings" - "github.com/eolinker/goku-eosc/node/http-proxy/backend" + "github.com/eolinker/goku/node/http-proxy/backend" ) type response struct { diff --git a/router/create.go b/router/create.go index c2b18af7..b499597c 100644 --- a/router/create.go +++ b/router/create.go @@ -10,9 +10,10 @@ package router import ( "fmt" - "github.com/eolinker/goku-eosc/router/checker" "sort" "strings" + + "github.com/eolinker/goku/router/checker" ) type RulePath struct { diff --git a/router/create_test.go b/router/create_test.go index fad106de..28497709 100644 --- a/router/create_test.go +++ b/router/create_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/eolinker/goku-eosc/router/checker" + "github.com/eolinker/goku/router/checker" ) type testSource map[string]string diff --git a/router/http-router/config.go b/router/http-router/config.go index 01199084..71225199 100644 --- a/router/http-router/config.go +++ b/router/http-router/config.go @@ -2,8 +2,8 @@ package http_router import ( "github.com/eolinker/eosc" - router_http "github.com/eolinker/goku-eosc/router/router-http" - "github.com/eolinker/goku-eosc/service" + router_http "github.com/eolinker/goku/router/router-http" + "github.com/eolinker/goku/service" ) type DriverConfig struct { @@ -14,7 +14,7 @@ type DriverConfig struct { Rules []DriverRule `json:"rules" yaml:"rules"` Protocol string `json:"protocol" yaml:"protocol"` Cert []Cert `json:"cert" yaml:"cert"` - Target eosc.RequireId `json:"target" yaml:"target" skill:"github.com/eolinker/goku-eosc/service.service.IService"` + Target eosc.RequireId `json:"target" yaml:"target" skill:"github.com/eolinker/goku/service.service.IService"` } type DriverRule struct { diff --git a/router/http-router/driver.go b/router/http-router/driver.go index 8fbad108..978371e8 100644 --- a/router/http-router/driver.go +++ b/router/http-router/driver.go @@ -2,9 +2,10 @@ package http_router import ( "fmt" - "github.com/eolinker/goku-eosc/service" "reflect" + "github.com/eolinker/goku/service" + "github.com/eolinker/eosc" ) @@ -15,32 +16,32 @@ type HttpRouterDriver struct { func (h *HttpRouterDriver) Create(id, name string, v interface{}, workers map[eosc.RequireId]interface{}) (eosc.IWorker, error) { conf, iService, err := h.check(v, workers) - if err!= nil{ - return nil,err + if err != nil { + return nil, err } - return NewRouter(id,name,conf,iService),nil + return NewRouter(id, name, conf, iService), nil } -func (h*HttpRouterDriver)check(v interface{},workers map[eosc.RequireId]interface{})( *DriverConfig,service.IService,error) { - conf,ok:=v.(*DriverConfig) - if !ok{ - return nil, nil,fmt.Errorf("get %s but %s %w",eosc.TypeNameOf(v),eosc.TypeNameOf(new(DriverConfig)),eosc.ErrorRequire) +func (h *HttpRouterDriver) check(v interface{}, workers map[eosc.RequireId]interface{}) (*DriverConfig, service.IService, error) { + conf, ok := v.(*DriverConfig) + if !ok { + return nil, nil, fmt.Errorf("get %s but %s %w", eosc.TypeNameOf(v), eosc.TypeNameOf(new(DriverConfig)), eosc.ErrorRequire) } - ser,has:=workers[conf.Target] - if !has{ - return nil,nil,fmt.Errorf("target %w",eosc.ErrorRequire) + ser, has := workers[conf.Target] + if !has { + return nil, nil, fmt.Errorf("target %w", eosc.ErrorRequire) + } + target, ok := ser.(service.IService) + if !ok { + return nil, nil, fmt.Errorf("target %w", eosc.ErrorNotGetSillForRequire) } - target,ok:=ser.(service.IService) - if !ok{ - return nil,nil,fmt.Errorf("target %w",eosc.ErrorNotGetSillForRequire) - } - return conf,target,nil + return conf, target, nil } func NewHttpRouter(profession, name, label, desc string, params map[string]string) *HttpRouterDriver { return &HttpRouterDriver{ - configType:reflect.TypeOf(new(DriverConfig)), + configType: reflect.TypeOf(new(DriverConfig)), info: eosc.DriverInfo{ Name: name, Label: label, diff --git a/router/http-router/router.go b/router/http-router/router.go index 69735852..4384b177 100644 --- a/router/http-router/router.go +++ b/router/http-router/router.go @@ -2,8 +2,8 @@ package http_router import ( "github.com/eolinker/eosc" - router_http "github.com/eolinker/goku-eosc/router/router-http" - "github.com/eolinker/goku-eosc/service" + router_http "github.com/eolinker/goku/router/router-http" + "github.com/eolinker/goku/service" ) type Router struct { diff --git a/router/router-http/config.go b/router/router-http/config.go index 98640c9c..9db97a50 100644 --- a/router/router-http/config.go +++ b/router/router-http/config.go @@ -1,9 +1,9 @@ package router_http import ( - "github.com/eolinker/goku-eosc/router" - "github.com/eolinker/goku-eosc/router/checker" - "github.com/eolinker/goku-eosc/service" + "github.com/eolinker/goku/router" + "github.com/eolinker/goku/router/checker" + "github.com/eolinker/goku/service" ) type HeaderItem struct { diff --git a/router/router-http/endpoint.go b/router/router-http/endpoint.go index 5649aa96..81b4ad6f 100644 --- a/router/router-http/endpoint.go +++ b/router/router-http/endpoint.go @@ -11,9 +11,9 @@ package router_http import ( "sync" - "github.com/eolinker/goku-eosc/router" - "github.com/eolinker/goku-eosc/router/checker" - "github.com/eolinker/goku-eosc/service" + "github.com/eolinker/goku/router" + "github.com/eolinker/goku/router/checker" + "github.com/eolinker/goku/service" ) var _ service.IRouterEndpoint = (*EndPoint)(nil) diff --git a/router/router-http/match.go b/router/router-http/match.go index 29690358..6fc9f5a5 100644 --- a/router/router-http/match.go +++ b/router/router-http/match.go @@ -1,10 +1,10 @@ package router_http import ( - http_context "github.com/eolinker/goku-eosc/node/http-context" + http_context "github.com/eolinker/goku/node/http-context" - "github.com/eolinker/goku-eosc/router" - "github.com/eolinker/goku-eosc/service" + "github.com/eolinker/goku/router" + "github.com/eolinker/goku/service" ) type IMatcher interface { diff --git a/router/router-http/parse.go b/router/router-http/parse.go index 420c7edf..9d570914 100644 --- a/router/router-http/parse.go +++ b/router/router-http/parse.go @@ -1,9 +1,9 @@ package router_http import ( - "github.com/eolinker/goku-eosc/router" - "github.com/eolinker/goku-eosc/router/checker" - "github.com/eolinker/goku-eosc/service" + "github.com/eolinker/goku/router" + "github.com/eolinker/goku/router/checker" + "github.com/eolinker/goku/service" ) func parse(cs []*Config) (IMatcher, error) { diff --git a/router/router-http/router.go b/router/router-http/router.go index f15c2f27..9c50ca85 100644 --- a/router/router-http/router.go +++ b/router/router-http/router.go @@ -3,7 +3,7 @@ package router_http import ( "sync" - http_context "github.com/eolinker/goku-eosc/node/http-context" + http_context "github.com/eolinker/goku/node/http-context" "github.com/valyala/fasthttp" diff --git a/router/router.go b/router/router.go index c9268e51..694ef333 100644 --- a/router/router.go +++ b/router/router.go @@ -1,23 +1,23 @@ package router import ( - "github.com/eolinker/goku-eosc/router/checker" + "github.com/eolinker/goku/router/checker" ) type ISource interface { - Get(cmd string)(string,bool) + Get(cmd string) (string, bool) } type IRouter interface { - Router(source ISource)(endpoint IEndPoint,has bool) + Router(source ISource) (endpoint IEndPoint, has bool) } type Routers []IRouter -func (rs Routers) Router(source ISource) (IEndPoint, bool) { - for _,r:=range rs{ - if target,has:=r.Router(source);has{ - return target,has +func (rs Routers) Router(source ISource) (IEndPoint, bool) { + for _, r := range rs { + if target, has := r.Router(source); has { + return target, has } } return nil, false @@ -29,33 +29,30 @@ type Node struct { equals map[string]IRouter checkers []checker.Checker - nodes []IRouter - + nodes []IRouter } +func (n *Node) Router(source ISource) (IEndPoint, bool) { + v, has := source.Get(n.cmd) -func (n *Node) Router(source ISource) (IEndPoint, bool) { - - v,has:=source.Get(n.cmd) - - if has{ - if child,ok:= n.equals[v];ok{ - if target,ok:=child.Router(source);ok{ - return target,true + if has { + if child, ok := n.equals[v]; ok { + if target, ok := child.Router(source); ok { + return target, true } } } - for i,c:=range n.checkers{ - if c.Check(v,has){ - if target,ok:=n.nodes[i].Router(source);ok{ - return target,true + for i, c := range n.checkers { + if c.Check(v, has) { + if target, ok := n.nodes[i].Router(source); ok { + return target, true } } } - return nil,false + return nil, false } @@ -64,13 +61,13 @@ type NodeShut struct { endpoint IEndPoint } -func (n *NodeShut) Router(source ISource) (IEndPoint, bool) { - if e ,has:=n.next.Router(source);has{ - return e,has +func (n *NodeShut) Router(source ISource) (IEndPoint, bool) { + if e, has := n.next.Router(source); has { + return e, has } - return n.endpoint,true + return n.endpoint, true } func NewNodeShut(next IRouter, endpoint IEndPoint) IRouter { return &NodeShut{next: next, endpoint: endpoint} -} \ No newline at end of file +} diff --git a/service/service-http/config.go b/service/service-http/config.go index bb9139fc..f764f908 100644 --- a/service/service-http/config.go +++ b/service/service-http/config.go @@ -17,8 +17,8 @@ type Config struct { Scheme string `json:"scheme"` RewriteURL string `json:"rewrite_url"` ProxyMethod string `json:"proxy_method"` - Auth []eosc.RequireId `json:"auth" skill:"github.com/eolinker/goku-eosc/auth.auth.IAuth"` - Upstream eosc.RequireId `json:"upstream" skill:"github.com/eolinker/goku-eosc/upstream.upstream.IUpstream" require:"false"` + Auth []eosc.RequireId `json:"auth" skill:"github.com/eolinker/goku/auth.auth.IAuth"` + Upstream eosc.RequireId `json:"upstream" skill:"github.com/eolinker/goku/upstream.upstream.IUpstream" require:"false"` } var validMethods = []string{ diff --git a/service/service-http/service.go b/service/service-http/service.go index 5c6ab093..303d7443 100644 --- a/service/service-http/service.go +++ b/service/service-http/service.go @@ -8,21 +8,21 @@ import ( "github.com/valyala/fasthttp" - http_proxy "github.com/eolinker/goku-eosc/node/http-proxy" - "github.com/eolinker/goku-eosc/utils" + http_proxy "github.com/eolinker/goku/node/http-proxy" + "github.com/eolinker/goku/utils" "github.com/eolinker/eosc/log" - "github.com/eolinker/goku-eosc/auth" + "github.com/eolinker/goku/auth" - "github.com/eolinker/goku-eosc/router/checker" + "github.com/eolinker/goku/router/checker" "github.com/eolinker/eosc" - "github.com/eolinker/goku-eosc/upstream" + "github.com/eolinker/goku/upstream" - http_context "github.com/eolinker/goku-eosc/node/http-context" + http_context "github.com/eolinker/goku/node/http-context" - "github.com/eolinker/goku-eosc/service" + "github.com/eolinker/goku/service" ) var ( diff --git a/service/service-http/service_test.go b/service/service-http/service_test.go index b143bf3f..44f40244 100644 --- a/service/service-http/service_test.go +++ b/service/service-http/service_test.go @@ -6,14 +6,14 @@ import ( "strings" "testing" - "github.com/eolinker/goku-eosc/service" + "github.com/eolinker/goku/service" - upstream_http "github.com/eolinker/goku-eosc/upstream/upstream-http" + upstream_http "github.com/eolinker/goku/upstream/upstream-http" "github.com/eolinker/eosc" - "github.com/eolinker/goku-eosc/discovery/static" - "github.com/eolinker/goku-eosc/upstream" - round_robin "github.com/eolinker/goku-eosc/upstream/round-robin" + "github.com/eolinker/goku/discovery/static" + "github.com/eolinker/goku/upstream" + round_robin "github.com/eolinker/goku/upstream/round-robin" ) type routerDemo struct { diff --git a/service/service.go b/service/service.go index 1ac0e487..af756ec9 100644 --- a/service/service.go +++ b/service/service.go @@ -3,16 +3,16 @@ package service import ( "time" - http_context "github.com/eolinker/goku-eosc/node/http-context" - "github.com/eolinker/goku-eosc/router/checker" + http_context "github.com/eolinker/goku/node/http-context" + "github.com/eolinker/goku/router/checker" ) //CheckSkill 检查目标技能是否符合 func CheckSkill(skill string) bool { - return skill == "github.com/eolinker/goku-eosc/service.service.IService" + return skill == "github.com/eolinker/goku/service.service.IService" } -//IService github.com/eolinker/goku-eosc/service.service.IService +//IService github.com/eolinker/goku/service.service.IService type IService interface { Handle(ctx *http_context.Context, router IRouterEndpoint) error } diff --git a/upstream/balance/balance.go b/upstream/balance/balance.go index 48138b32..0c06ac4a 100644 --- a/upstream/balance/balance.go +++ b/upstream/balance/balance.go @@ -4,7 +4,7 @@ import ( "errors" "github.com/eolinker/eosc" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" ) var ( diff --git a/upstream/round-robin/round_robin.go b/upstream/round-robin/round_robin.go index ad537fe7..5429cbc2 100644 --- a/upstream/round-robin/round_robin.go +++ b/upstream/round-robin/round_robin.go @@ -5,8 +5,8 @@ import ( "strconv" "time" - "github.com/eolinker/goku-eosc/discovery" - "github.com/eolinker/goku-eosc/upstream/balance" + "github.com/eolinker/goku/discovery" + "github.com/eolinker/goku/upstream/balance" ) const ( diff --git a/upstream/round-robin/round_robin_test.go b/upstream/round-robin/round_robin_test.go index dfe10b40..2238cd38 100644 --- a/upstream/round-robin/round_robin_test.go +++ b/upstream/round-robin/round_robin_test.go @@ -3,7 +3,7 @@ package round_robin import ( "testing" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" ) type discoveryDemo struct { diff --git a/upstream/upstream-http/config.go b/upstream/upstream-http/config.go index 0b65b29e..03a6bbeb 100644 --- a/upstream/upstream-http/config.go +++ b/upstream/upstream-http/config.go @@ -10,5 +10,5 @@ type Config struct { Scheme string `json:"scheme"` Type string `json:"type"` Config string `json:"config"` - Discovery eosc.RequireId `json:"discovery" skill:"github.com/eolinker/goku-eosc/discovery.discovery.IDiscovery"` + Discovery eosc.RequireId `json:"discovery" skill:"github.com/eolinker/goku/discovery.discovery.IDiscovery"` } diff --git a/upstream/upstream-http/driver.go b/upstream/upstream-http/driver.go index 3937c370..3dbf07fa 100644 --- a/upstream/upstream-http/driver.go +++ b/upstream/upstream-http/driver.go @@ -3,7 +3,7 @@ package upstream_http import ( "reflect" - round_robin "github.com/eolinker/goku-eosc/upstream/round-robin" + round_robin "github.com/eolinker/goku/upstream/round-robin" "github.com/eolinker/eosc" ) diff --git a/upstream/upstream-http/upstream.go b/upstream/upstream-http/upstream.go index a4101741..64230c19 100644 --- a/upstream/upstream-http/upstream.go +++ b/upstream/upstream-http/upstream.go @@ -6,20 +6,20 @@ import ( "github.com/valyala/fasthttp" - "github.com/eolinker/goku-eosc/upstream" + "github.com/eolinker/goku/upstream" "github.com/eolinker/eosc" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" - "github.com/eolinker/goku-eosc/service" + "github.com/eolinker/goku/service" - "github.com/eolinker/goku-eosc/upstream/balance" + "github.com/eolinker/goku/upstream/balance" - http_proxy "github.com/eolinker/goku-eosc/node/http-proxy" + http_proxy "github.com/eolinker/goku/node/http-proxy" - http_context "github.com/eolinker/goku-eosc/node/http-context" + http_context "github.com/eolinker/goku/node/http-context" - "github.com/eolinker/goku-eosc/utils" + "github.com/eolinker/goku/utils" ) var ( diff --git a/upstream/upstream-http/upstream_test.go b/upstream/upstream-http/upstream_test.go index 2cfdb70f..f7e92484 100644 --- a/upstream/upstream-http/upstream_test.go +++ b/upstream/upstream-http/upstream_test.go @@ -9,12 +9,12 @@ import ( "github.com/eolinker/eosc" - "github.com/eolinker/goku-eosc/discovery" + "github.com/eolinker/goku/discovery" "github.com/go-basic/uuid" - http_context "github.com/eolinker/goku-eosc/node/http-context" - "github.com/eolinker/goku-eosc/upstream" + http_context "github.com/eolinker/goku/node/http-context" + "github.com/eolinker/goku/upstream" ) var ( diff --git a/upstream/upstream-http_anonymous/org.go b/upstream/upstream-http_anonymous/org.go index cba92ac0..b78371c2 100644 --- a/upstream/upstream-http_anonymous/org.go +++ b/upstream/upstream-http_anonymous/org.go @@ -5,13 +5,13 @@ import ( "github.com/valyala/fasthttp" - "github.com/eolinker/goku-eosc/service" + "github.com/eolinker/goku/service" - http_proxy "github.com/eolinker/goku-eosc/node/http-proxy" + http_proxy "github.com/eolinker/goku/node/http-proxy" - http_context "github.com/eolinker/goku-eosc/node/http-context" + http_context "github.com/eolinker/goku/node/http-context" - "github.com/eolinker/goku-eosc/utils" + "github.com/eolinker/goku/utils" ) func NewAnonymousUpstream() *httpUpstream { diff --git a/upstream/upstream.go b/upstream/upstream.go index 39d42f91..fe15bf2d 100644 --- a/upstream/upstream.go +++ b/upstream/upstream.go @@ -1,14 +1,14 @@ package upstream import ( - http_context "github.com/eolinker/goku-eosc/node/http-context" - "github.com/eolinker/goku-eosc/service" + http_context "github.com/eolinker/goku/node/http-context" + "github.com/eolinker/goku/service" "github.com/valyala/fasthttp" ) //CheckSkill 检测目标技能是否符合 func CheckSkill(skill string) bool { - return skill == "github.com/eolinker/goku-eosc/upstream.upstream.IUpstream" + return skill == "github.com/eolinker/goku/upstream.upstream.IUpstream" } //IUpstream 实现了负载发送请求方法 diff --git a/upstream/upstream_test.go b/upstream/upstream_test.go index 34de355e..5781eb9f 100644 --- a/upstream/upstream_test.go +++ b/upstream/upstream_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/eolinker/goku-eosc/auth" + "github.com/eolinker/goku/auth" "github.com/eolinker/eosc" )