diff --git a/codegen/template_bundle/template_files.go b/codegen/template_bundle/template_files.go index 42cd70e26..65bff722b 100644 --- a/codegen/template_bundle/template_files.go +++ b/codegen/template_bundle/template_files.go @@ -68,24 +68,17 @@ import ( {{end -}} {{end}} - "github.com/uber-go/tally" - "go.uber.org/zap" + zanzibar "github.com/uber/zanzibar/runtime" ) // Dependencies contains dependencies for the {{$instance.InstanceName}} {{$instance.ClassName}} module type Dependencies struct { - Default *DefaultDependencies + Default *zanzibar.DefaultDependencies {{range $classType, $moduleInstances := $instance.ResolvedDependencies -}} {{$classType | pascal}} *{{$classType | pascal}}Dependencies {{end -}} } -// DefaultDependencies contains default dependencies, such as logger and scope. -type DefaultDependencies struct { - Logger *zap.Logger - Scope tally.Scope -} - {{range $classType, $moduleInstances := $instance.ResolvedDependencies -}} // {{$classType | pascal}}Dependencies contains {{$classType}} dependencies type {{$classType | pascal}}Dependencies struct { @@ -107,7 +100,7 @@ func dependency_structTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "dependency_struct.tmpl", size: 1330, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "dependency_struct.tmpl", size: 1180, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -1335,7 +1328,7 @@ import ( {{end -}} {{end}} - "github.com/uber/zanzibar/runtime" + zanzibar "github.com/uber/zanzibar/runtime" ) // DependenciesTree contains all deps for this service. @@ -1362,6 +1355,13 @@ func InitializeDependencies( ) (*DependenciesTree, *Dependencies) { tree := &DependenciesTree{} + initializedDefaultDependencies := &zanzibar.DefaultDependencies{ + Logger: gateway.Logger, + Scope: gateway.AllHostScope, + Config: gateway.Config, + Channel: gateway.Channel, + } + {{range $idx, $className := $instance.DependencyOrder}} {{- $moduleInstances := (index $instance.RecursiveDependencies $className)}} initialized{{$className | pascal}}Dependencies := &{{$className | title}}DependenciesNodes{} @@ -1369,10 +1369,7 @@ func InitializeDependencies( {{- range $idx, $dependency := $moduleInstances}} initialized{{$className | pascal}}Dependencies.{{$dependency.PackageInfo.QualifiedInstanceName}} = {{$dependency.PackageInfo.ImportPackageAlias}}.{{$dependency.PackageInfo.ExportName}}(gateway, &{{$dependency.PackageInfo.ModulePackageAlias}}.Dependencies{ - Default: &{{$dependency.PackageInfo.ModulePackageAlias}}.DefaultDependencies{ - Logger: gateway.Logger, - Scope: gateway.AllHostScope, - }, + Default: initializedDefaultDependencies, {{- range $className, $moduleInstances := $dependency.ResolvedDependencies}} {{$className | pascal}}: &{{$dependency.PackageInfo.ModulePackageAlias}}.{{$className | pascal}}Dependencies{ {{- range $idy, $subDependency := $moduleInstances}} @@ -1385,10 +1382,7 @@ func InitializeDependencies( {{end}} return tree, &Dependencies{ - Default: &DefaultDependencies{ - Logger: gateway.Logger, - Scope: gateway.AllHostScope, - }, + Default: initializedDefaultDependencies, {{- range $className, $moduleInstances := $instance.ResolvedDependencies}} {{$className | pascal}}: &{{$className | pascal}}Dependencies{ {{- range $idy, $subDependency := $moduleInstances}} @@ -1410,7 +1404,7 @@ func module_initializerTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "module_initializer.tmpl", size: 3158, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "module_initializer.tmpl", size: 3195, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/codegen/templates/dependency_struct.tmpl b/codegen/templates/dependency_struct.tmpl index 2c544c394..b3ba9597f 100644 --- a/codegen/templates/dependency_struct.tmpl +++ b/codegen/templates/dependency_struct.tmpl @@ -8,24 +8,17 @@ import ( {{end -}} {{end}} - "github.com/uber-go/tally" - "go.uber.org/zap" + zanzibar "github.com/uber/zanzibar/runtime" ) // Dependencies contains dependencies for the {{$instance.InstanceName}} {{$instance.ClassName}} module type Dependencies struct { - Default *DefaultDependencies + Default *zanzibar.DefaultDependencies {{range $classType, $moduleInstances := $instance.ResolvedDependencies -}} {{$classType | pascal}} *{{$classType | pascal}}Dependencies {{end -}} } -// DefaultDependencies contains default dependencies, such as logger and scope. -type DefaultDependencies struct { - Logger *zap.Logger - Scope tally.Scope -} - {{range $classType, $moduleInstances := $instance.ResolvedDependencies -}} // {{$classType | pascal}}Dependencies contains {{$classType}} dependencies type {{$classType | pascal}}Dependencies struct { diff --git a/codegen/templates/module_initializer.tmpl b/codegen/templates/module_initializer.tmpl index ebb864262..80bf2762d 100644 --- a/codegen/templates/module_initializer.tmpl +++ b/codegen/templates/module_initializer.tmpl @@ -10,7 +10,7 @@ import ( {{end -}} {{end}} - "github.com/uber/zanzibar/runtime" + zanzibar "github.com/uber/zanzibar/runtime" ) // DependenciesTree contains all deps for this service. @@ -37,6 +37,13 @@ func InitializeDependencies( ) (*DependenciesTree, *Dependencies) { tree := &DependenciesTree{} + initializedDefaultDependencies := &zanzibar.DefaultDependencies{ + Logger: gateway.Logger, + Scope: gateway.AllHostScope, + Config: gateway.Config, + Channel: gateway.Channel, + } + {{range $idx, $className := $instance.DependencyOrder}} {{- $moduleInstances := (index $instance.RecursiveDependencies $className)}} initialized{{$className | pascal}}Dependencies := &{{$className | title}}DependenciesNodes{} @@ -44,10 +51,7 @@ func InitializeDependencies( {{- range $idx, $dependency := $moduleInstances}} initialized{{$className | pascal}}Dependencies.{{$dependency.PackageInfo.QualifiedInstanceName}} = {{$dependency.PackageInfo.ImportPackageAlias}}.{{$dependency.PackageInfo.ExportName}}(gateway, &{{$dependency.PackageInfo.ModulePackageAlias}}.Dependencies{ - Default: &{{$dependency.PackageInfo.ModulePackageAlias}}.DefaultDependencies{ - Logger: gateway.Logger, - Scope: gateway.AllHostScope, - }, + Default: initializedDefaultDependencies, {{- range $className, $moduleInstances := $dependency.ResolvedDependencies}} {{$className | pascal}}: &{{$dependency.PackageInfo.ModulePackageAlias}}.{{$className | pascal}}Dependencies{ {{- range $idy, $subDependency := $moduleInstances}} @@ -60,10 +64,7 @@ func InitializeDependencies( {{end}} return tree, &Dependencies{ - Default: &DefaultDependencies{ - Logger: gateway.Logger, - Scope: gateway.AllHostScope, - }, + Default: initializedDefaultDependencies, {{- range $className, $moduleInstances := $instance.ResolvedDependencies}} {{$className | pascal}}: &{{$className | pascal}}Dependencies{ {{- range $idy, $subDependency := $moduleInstances}} diff --git a/examples/example-gateway/build/clients/bar/module/dependencies.go b/examples/example-gateway/build/clients/bar/module/dependencies.go index 94cc14fea..9a8cae1f3 100644 --- a/examples/example-gateway/build/clients/bar/module/dependencies.go +++ b/examples/example-gateway/build/clients/bar/module/dependencies.go @@ -24,17 +24,10 @@ package module import ( - "github.com/uber-go/tally" - "go.uber.org/zap" + zanzibar "github.com/uber/zanzibar/runtime" ) // Dependencies contains dependencies for the bar client module type Dependencies struct { - Default *DefaultDependencies -} - -// DefaultDependencies contains default dependencies, such as logger and scope. -type DefaultDependencies struct { - Logger *zap.Logger - Scope tally.Scope + Default *zanzibar.DefaultDependencies } diff --git a/examples/example-gateway/build/clients/baz/module/dependencies.go b/examples/example-gateway/build/clients/baz/module/dependencies.go index 1f3eed09c..72c2ca0ce 100644 --- a/examples/example-gateway/build/clients/baz/module/dependencies.go +++ b/examples/example-gateway/build/clients/baz/module/dependencies.go @@ -24,17 +24,10 @@ package module import ( - "github.com/uber-go/tally" - "go.uber.org/zap" + zanzibar "github.com/uber/zanzibar/runtime" ) // Dependencies contains dependencies for the baz client module type Dependencies struct { - Default *DefaultDependencies -} - -// DefaultDependencies contains default dependencies, such as logger and scope. -type DefaultDependencies struct { - Logger *zap.Logger - Scope tally.Scope + Default *zanzibar.DefaultDependencies } diff --git a/examples/example-gateway/build/clients/contacts/module/dependencies.go b/examples/example-gateway/build/clients/contacts/module/dependencies.go index 910f7b8cb..aa2f36ab5 100644 --- a/examples/example-gateway/build/clients/contacts/module/dependencies.go +++ b/examples/example-gateway/build/clients/contacts/module/dependencies.go @@ -24,17 +24,10 @@ package module import ( - "github.com/uber-go/tally" - "go.uber.org/zap" + zanzibar "github.com/uber/zanzibar/runtime" ) // Dependencies contains dependencies for the contacts client module type Dependencies struct { - Default *DefaultDependencies -} - -// DefaultDependencies contains default dependencies, such as logger and scope. -type DefaultDependencies struct { - Logger *zap.Logger - Scope tally.Scope + Default *zanzibar.DefaultDependencies } diff --git a/examples/example-gateway/build/clients/corge/module/dependencies.go b/examples/example-gateway/build/clients/corge/module/dependencies.go index 32a1aa012..057baef9f 100644 --- a/examples/example-gateway/build/clients/corge/module/dependencies.go +++ b/examples/example-gateway/build/clients/corge/module/dependencies.go @@ -24,17 +24,10 @@ package module import ( - "github.com/uber-go/tally" - "go.uber.org/zap" + zanzibar "github.com/uber/zanzibar/runtime" ) // Dependencies contains dependencies for the corge client module type Dependencies struct { - Default *DefaultDependencies -} - -// DefaultDependencies contains default dependencies, such as logger and scope. -type DefaultDependencies struct { - Logger *zap.Logger - Scope tally.Scope + Default *zanzibar.DefaultDependencies } diff --git a/examples/example-gateway/build/clients/google-now/module/dependencies.go b/examples/example-gateway/build/clients/google-now/module/dependencies.go index 4de0b9491..6814ca017 100644 --- a/examples/example-gateway/build/clients/google-now/module/dependencies.go +++ b/examples/example-gateway/build/clients/google-now/module/dependencies.go @@ -24,17 +24,10 @@ package module import ( - "github.com/uber-go/tally" - "go.uber.org/zap" + zanzibar "github.com/uber/zanzibar/runtime" ) // Dependencies contains dependencies for the google-now client module type Dependencies struct { - Default *DefaultDependencies -} - -// DefaultDependencies contains default dependencies, such as logger and scope. -type DefaultDependencies struct { - Logger *zap.Logger - Scope tally.Scope + Default *zanzibar.DefaultDependencies } diff --git a/examples/example-gateway/build/clients/quux/module/dependencies.go b/examples/example-gateway/build/clients/quux/module/dependencies.go index 379b48c8e..dcc1bc757 100644 --- a/examples/example-gateway/build/clients/quux/module/dependencies.go +++ b/examples/example-gateway/build/clients/quux/module/dependencies.go @@ -26,22 +26,15 @@ package module import ( barClientGenerated "github.com/uber/zanzibar/examples/example-gateway/build/clients/bar" - "github.com/uber-go/tally" - "go.uber.org/zap" + zanzibar "github.com/uber/zanzibar/runtime" ) // Dependencies contains dependencies for the quux client module type Dependencies struct { - Default *DefaultDependencies + Default *zanzibar.DefaultDependencies Client *ClientDependencies } -// DefaultDependencies contains default dependencies, such as logger and scope. -type DefaultDependencies struct { - Logger *zap.Logger - Scope tally.Scope -} - // ClientDependencies contains client dependencies type ClientDependencies struct { Bar barClientGenerated.Client diff --git a/examples/example-gateway/build/endpoints/bar/module/dependencies.go b/examples/example-gateway/build/endpoints/bar/module/dependencies.go index 009e70f44..ecc5831cb 100644 --- a/examples/example-gateway/build/endpoints/bar/module/dependencies.go +++ b/examples/example-gateway/build/endpoints/bar/module/dependencies.go @@ -26,22 +26,15 @@ package module import ( barClientGenerated "github.com/uber/zanzibar/examples/example-gateway/build/clients/bar" - "github.com/uber-go/tally" - "go.uber.org/zap" + zanzibar "github.com/uber/zanzibar/runtime" ) // Dependencies contains dependencies for the bar endpoint module type Dependencies struct { - Default *DefaultDependencies + Default *zanzibar.DefaultDependencies Client *ClientDependencies } -// DefaultDependencies contains default dependencies, such as logger and scope. -type DefaultDependencies struct { - Logger *zap.Logger - Scope tally.Scope -} - // ClientDependencies contains client dependencies type ClientDependencies struct { Bar barClientGenerated.Client diff --git a/examples/example-gateway/build/endpoints/baz/module/dependencies.go b/examples/example-gateway/build/endpoints/baz/module/dependencies.go index cfeef57b3..1a7befed2 100644 --- a/examples/example-gateway/build/endpoints/baz/module/dependencies.go +++ b/examples/example-gateway/build/endpoints/baz/module/dependencies.go @@ -26,22 +26,15 @@ package module import ( bazClientGenerated "github.com/uber/zanzibar/examples/example-gateway/build/clients/baz" - "github.com/uber-go/tally" - "go.uber.org/zap" + zanzibar "github.com/uber/zanzibar/runtime" ) // Dependencies contains dependencies for the baz endpoint module type Dependencies struct { - Default *DefaultDependencies + Default *zanzibar.DefaultDependencies Client *ClientDependencies } -// DefaultDependencies contains default dependencies, such as logger and scope. -type DefaultDependencies struct { - Logger *zap.Logger - Scope tally.Scope -} - // ClientDependencies contains client dependencies type ClientDependencies struct { Baz bazClientGenerated.Client diff --git a/examples/example-gateway/build/endpoints/contacts/module/dependencies.go b/examples/example-gateway/build/endpoints/contacts/module/dependencies.go index 731c63c69..eaf3bc116 100644 --- a/examples/example-gateway/build/endpoints/contacts/module/dependencies.go +++ b/examples/example-gateway/build/endpoints/contacts/module/dependencies.go @@ -26,22 +26,15 @@ package module import ( contactsClientGenerated "github.com/uber/zanzibar/examples/example-gateway/build/clients/contacts" - "github.com/uber-go/tally" - "go.uber.org/zap" + zanzibar "github.com/uber/zanzibar/runtime" ) // Dependencies contains dependencies for the contacts endpoint module type Dependencies struct { - Default *DefaultDependencies + Default *zanzibar.DefaultDependencies Client *ClientDependencies } -// DefaultDependencies contains default dependencies, such as logger and scope. -type DefaultDependencies struct { - Logger *zap.Logger - Scope tally.Scope -} - // ClientDependencies contains client dependencies type ClientDependencies struct { Contacts contactsClientGenerated.Client diff --git a/examples/example-gateway/build/endpoints/googlenow/module/dependencies.go b/examples/example-gateway/build/endpoints/googlenow/module/dependencies.go index 53b9e1845..1a5a0484c 100644 --- a/examples/example-gateway/build/endpoints/googlenow/module/dependencies.go +++ b/examples/example-gateway/build/endpoints/googlenow/module/dependencies.go @@ -26,22 +26,15 @@ package module import ( googlenowClientGenerated "github.com/uber/zanzibar/examples/example-gateway/build/clients/google-now" - "github.com/uber-go/tally" - "go.uber.org/zap" + zanzibar "github.com/uber/zanzibar/runtime" ) // Dependencies contains dependencies for the googlenow endpoint module type Dependencies struct { - Default *DefaultDependencies + Default *zanzibar.DefaultDependencies Client *ClientDependencies } -// DefaultDependencies contains default dependencies, such as logger and scope. -type DefaultDependencies struct { - Logger *zap.Logger - Scope tally.Scope -} - // ClientDependencies contains client dependencies type ClientDependencies struct { GoogleNow googlenowClientGenerated.Client diff --git a/examples/example-gateway/build/endpoints/tchannel/baz/module/dependencies.go b/examples/example-gateway/build/endpoints/tchannel/baz/module/dependencies.go index 5c4b01a83..45bf9fd0e 100644 --- a/examples/example-gateway/build/endpoints/tchannel/baz/module/dependencies.go +++ b/examples/example-gateway/build/endpoints/tchannel/baz/module/dependencies.go @@ -26,22 +26,15 @@ package module import ( bazClientGenerated "github.com/uber/zanzibar/examples/example-gateway/build/clients/baz" - "github.com/uber-go/tally" - "go.uber.org/zap" + zanzibar "github.com/uber/zanzibar/runtime" ) // Dependencies contains dependencies for the bazTChannel endpoint module type Dependencies struct { - Default *DefaultDependencies + Default *zanzibar.DefaultDependencies Client *ClientDependencies } -// DefaultDependencies contains default dependencies, such as logger and scope. -type DefaultDependencies struct { - Logger *zap.Logger - Scope tally.Scope -} - // ClientDependencies contains client dependencies type ClientDependencies struct { Baz bazClientGenerated.Client diff --git a/examples/example-gateway/build/services/example-gateway/module/dependencies.go b/examples/example-gateway/build/services/example-gateway/module/dependencies.go index 2bc691b7d..f8a869a83 100644 --- a/examples/example-gateway/build/services/example-gateway/module/dependencies.go +++ b/examples/example-gateway/build/services/example-gateway/module/dependencies.go @@ -30,22 +30,15 @@ import ( googlenowEndpointGenerated "github.com/uber/zanzibar/examples/example-gateway/build/endpoints/googlenow" baztchannelEndpointGenerated "github.com/uber/zanzibar/examples/example-gateway/build/endpoints/tchannel/baz" - "github.com/uber-go/tally" - "go.uber.org/zap" + zanzibar "github.com/uber/zanzibar/runtime" ) // Dependencies contains dependencies for the example-gateway service module type Dependencies struct { - Default *DefaultDependencies + Default *zanzibar.DefaultDependencies Endpoint *EndpointDependencies } -// DefaultDependencies contains default dependencies, such as logger and scope. -type DefaultDependencies struct { - Logger *zap.Logger - Scope tally.Scope -} - // EndpointDependencies contains endpoint dependencies type EndpointDependencies struct { Bar barEndpointGenerated.Endpoint diff --git a/examples/example-gateway/build/services/example-gateway/module/init.go b/examples/example-gateway/build/services/example-gateway/module/init.go index 9ed3b3027..31df15f4f 100644 --- a/examples/example-gateway/build/services/example-gateway/module/init.go +++ b/examples/example-gateway/build/services/example-gateway/module/init.go @@ -43,7 +43,7 @@ import ( baztchannelEndpointGenerated "github.com/uber/zanzibar/examples/example-gateway/build/endpoints/tchannel/baz" baztchannelEndpointModule "github.com/uber/zanzibar/examples/example-gateway/build/endpoints/tchannel/baz/module" - "github.com/uber/zanzibar/runtime" + zanzibar "github.com/uber/zanzibar/runtime" ) // DependenciesTree contains all deps for this service. @@ -76,86 +76,63 @@ func InitializeDependencies( ) (*DependenciesTree, *Dependencies) { tree := &DependenciesTree{} + initializedDefaultDependencies := &zanzibar.DefaultDependencies{ + Logger: gateway.Logger, + Scope: gateway.AllHostScope, + Config: gateway.Config, + Channel: gateway.Channel, + } + initializedClientDependencies := &ClientDependenciesNodes{} tree.Client = initializedClientDependencies initializedClientDependencies.Bar = barClientGenerated.NewClient(gateway, &barClientModule.Dependencies{ - Default: &barClientModule.DefaultDependencies{ - Logger: gateway.Logger, - Scope: gateway.AllHostScope, - }, + Default: initializedDefaultDependencies, }) initializedClientDependencies.Baz = bazClientGenerated.NewClient(gateway, &bazClientModule.Dependencies{ - Default: &bazClientModule.DefaultDependencies{ - Logger: gateway.Logger, - Scope: gateway.AllHostScope, - }, + Default: initializedDefaultDependencies, }) initializedClientDependencies.Contacts = contactsClientGenerated.NewClient(gateway, &contactsClientModule.Dependencies{ - Default: &contactsClientModule.DefaultDependencies{ - Logger: gateway.Logger, - Scope: gateway.AllHostScope, - }, + Default: initializedDefaultDependencies, }) initializedClientDependencies.GoogleNow = googlenowClientGenerated.NewClient(gateway, &googlenowClientModule.Dependencies{ - Default: &googlenowClientModule.DefaultDependencies{ - Logger: gateway.Logger, - Scope: gateway.AllHostScope, - }, + Default: initializedDefaultDependencies, }) initializedEndpointDependencies := &EndpointDependenciesNodes{} tree.Endpoint = initializedEndpointDependencies initializedEndpointDependencies.Bar = barEndpointGenerated.NewEndpoint(gateway, &barEndpointModule.Dependencies{ - Default: &barEndpointModule.DefaultDependencies{ - Logger: gateway.Logger, - Scope: gateway.AllHostScope, - }, + Default: initializedDefaultDependencies, Client: &barEndpointModule.ClientDependencies{ Bar: initializedClientDependencies.Bar, }, }) initializedEndpointDependencies.Baz = bazEndpointGenerated.NewEndpoint(gateway, &bazEndpointModule.Dependencies{ - Default: &bazEndpointModule.DefaultDependencies{ - Logger: gateway.Logger, - Scope: gateway.AllHostScope, - }, + Default: initializedDefaultDependencies, Client: &bazEndpointModule.ClientDependencies{ Baz: initializedClientDependencies.Baz, }, }) initializedEndpointDependencies.BazTChannel = baztchannelEndpointGenerated.NewEndpoint(gateway, &baztchannelEndpointModule.Dependencies{ - Default: &baztchannelEndpointModule.DefaultDependencies{ - Logger: gateway.Logger, - Scope: gateway.AllHostScope, - }, + Default: initializedDefaultDependencies, Client: &baztchannelEndpointModule.ClientDependencies{ Baz: initializedClientDependencies.Baz, }, }) initializedEndpointDependencies.Contacts = contactsEndpointGenerated.NewEndpoint(gateway, &contactsEndpointModule.Dependencies{ - Default: &contactsEndpointModule.DefaultDependencies{ - Logger: gateway.Logger, - Scope: gateway.AllHostScope, - }, + Default: initializedDefaultDependencies, Client: &contactsEndpointModule.ClientDependencies{ Contacts: initializedClientDependencies.Contacts, }, }) initializedEndpointDependencies.Googlenow = googlenowEndpointGenerated.NewEndpoint(gateway, &googlenowEndpointModule.Dependencies{ - Default: &googlenowEndpointModule.DefaultDependencies{ - Logger: gateway.Logger, - Scope: gateway.AllHostScope, - }, + Default: initializedDefaultDependencies, Client: &googlenowEndpointModule.ClientDependencies{ GoogleNow: initializedClientDependencies.GoogleNow, }, }) return tree, &Dependencies{ - Default: &DefaultDependencies{ - Logger: gateway.Logger, - Scope: gateway.AllHostScope, - }, + Default: initializedDefaultDependencies, Endpoint: &EndpointDependencies{ Bar: initializedEndpointDependencies.Bar, Baz: initializedEndpointDependencies.Baz, diff --git a/runtime/gateway.go b/runtime/gateway.go index a52ebe0c7..0f191ceb6 100644 --- a/runtime/gateway.go +++ b/runtime/gateway.go @@ -83,6 +83,14 @@ type Gateway struct { // - process reporter ? } +// DefaultDependencies type +type DefaultDependencies struct { + Logger *zap.Logger + Scope tally.Scope + Config *StaticConfig + Channel *tchannel.Channel +} + // CreateGateway func func CreateGateway( config *StaticConfig, opts *Options,