diff --git a/cmd/api/option/option.go b/cmd/api/option/option.go index 225daa7f3..b45fdce45 100644 --- a/cmd/api/option/option.go +++ b/cmd/api/option/option.go @@ -33,6 +33,7 @@ type Config struct { DBConnectionInfo string EventLogServers []string NodeAPI []string + BuilderAPI []string EntranceAPI []string V1API string MQAPI string @@ -77,6 +78,7 @@ func (a *APIServer) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&a.WebsocketKeyFile, "ws-ssl-keyfile", "/etc/ssl/goodrain.com/goodrain.com.key", "websocket and fileserver ssl key file") fs.StringVar(&a.V1API, "v1-api", "127.0.0.1:8887", "the region v1 api") fs.StringSliceVar(&a.NodeAPI, "node-api", []string{"127.0.0.1:6100"}, "the node server api") + fs.StringSliceVar(&a.BuilderAPI, "builder-api", []string{"127.0.0.1:3228"}, "the builder api") fs.StringSliceVar(&a.EntranceAPI, "entrance-api", []string{"127.0.0.1:6200"}, "the entrance api") fs.StringSliceVar(&a.EventLogServers, "event-servers", []string{"127.0.0.1:6367"}, "event log server address. simple lb") fs.StringVar(&a.MQAPI, "mq-api", "127.0.0.1:6300", "acp_mq api") diff --git a/pkg/api/middleware/mideware.go b/pkg/api/middleware/mideware.go index 8f4d34277..96dd4f537 100644 --- a/pkg/api/middleware/mideware.go +++ b/pkg/api/middleware/mideware.go @@ -133,6 +133,10 @@ func Proxy(next http.Handler) http.Handler { GetNodeProxy().Proxy(w, r) return } + if strings.HasPrefix(r.RequestURI, "/v2/builder") { + GetBuilderProxy().Proxy(w, r) + return + } if strings.HasPrefix(r.RequestURI, "/v2/tasks") { GetNodeProxy().Proxy(w, r) return diff --git a/pkg/api/middleware/proxy.go b/pkg/api/middleware/proxy.go index 069f4baf4..7fcc7422f 100644 --- a/pkg/api/middleware/proxy.go +++ b/pkg/api/middleware/proxy.go @@ -25,6 +25,8 @@ import ( ) var nodeProxy proxy.Proxy +var builderProxy proxy.Proxy + //InitProxy 初始化 func InitProxy(conf option.Config) { @@ -32,9 +34,17 @@ func InitProxy(conf option.Config) { nodeProxy = proxy.CreateProxy("acp_node", "http", conf.NodeAPI) discover.GetEndpointDiscover(conf.EtcdEndpoint).AddProject("acp_node", nodeProxy) } + if builderProxy == nil { + builderProxy = proxy.CreateProxy("builder", "http", conf.NodeAPI) + discover.GetEndpointDiscover(conf.EtcdEndpoint).AddProject("acp_node", nodeProxy) + } } //GetNodeProxy GetNodeProxy func GetNodeProxy() proxy.Proxy { return nodeProxy } +//GetNodeProxy GetNodeProxy +func GetBuilderProxy() proxy.Proxy { + return builderProxy +} \ No newline at end of file