@@ -26,26 +26,27 @@ import (
2626// Avoid unused imports if there is configuration type
2727var _ = emptypb.Empty {}
2828
29- {{ range .Services }}
29+ {{- range .Services }}
3030{{ $hasTriggers := false }}
3131{{ $hasActions := false }}
32- {{ $service := . - }}
33- {{ if .Comments.Leading.String }}//{{ .GoName }}Capability {{CleanComments .Comments.Leading.String }} {{ end }}
34- type {{.GoName }}Capability interface { {{- if .Comments.Trailing.String }}//{{ .GoName }}Capability {{CleanComments .Comments.Trailing.String }} {{ end }}
32+ {{ $service := . }}
33+ {{ $fullCapabilityId := printf " \" %s \" %s " (CapabilityId $service ) (AppendLabels (Labels $service )) }}
34+ type {{.GoName }}Capability interface {
3535 {{- range .Methods }}
3636 {{- if isTrigger . }}
3737 {{ $hasTriggers = true }}
38- {{- if .Comments.Leading.String }}//Register{{.GoName }} registration for {{CleanComments .Comments.Leading.String }} {{ end }}
39- Register{{.GoName }}(ctx context.Context , triggerID string, metadata capabilities.RequestMetadata , input *{{ImportAlias .Input.GoIdent.GoImportPath }}. {{.Input.GoIdent.GoName }}) (<- chan capabilities.TriggerAndId [*{{ImportAlias .Output.GoIdent.GoImportPath }}. {{.Output.GoIdent.GoName }}], error) {{- if .Comments.Trailing.String }}// {{CleanComments .Comments.Trailing.String }} {{ end }}
40- {{ if .Comments.Leading.String }}//Unregister{{.GoName }} unregistration for {{CleanComments .Comments.Leading.String }} {{ end }}
41- Unregister{{.GoName }}(ctx context.Context , triggerID string, metadata capabilities.RequestMetadata , input *{{ImportAlias .Input.GoIdent.GoImportPath }}. {{.Input.GoIdent.GoName }}) error {{- if .Comments.Trailing.String }}// {{CleanComments .Comments.Trailing.String }} {{ end }}
38+ Register{{.GoName }}(ctx context.Context , triggerID string, metadata capabilities.RequestMetadata , input *{{ImportAlias .Input.GoIdent.GoImportPath }}. {{.Input.GoIdent.GoName }}) (<- chan capabilities.TriggerAndId [*{{ImportAlias .Output.GoIdent.GoImportPath }}. {{.Output.GoIdent.GoName }}], error)
39+ Unregister{{.GoName }}(ctx context.Context , triggerID string, metadata capabilities.RequestMetadata , input *{{ImportAlias .Input.GoIdent.GoImportPath }}. {{.Input.GoIdent.GoName }}) error
4240 {{- else }}
4341 {{ $hasActions = true }}
44- {{- if .Comments.Leading.String }}//{{.GoName }} {{CleanComments .Comments.Leading.String }} {{ end }}
45- {{.GoName }}(ctx context.Context , metadata capabilities.RequestMetadata , input *{{ImportAlias .Input.GoIdent.GoImportPath }}. {{.Input.GoIdent.GoName }} {{if ne " emptypb.Empty" (ConfigType $service )}}, {{(ConfigType $service )}}{{ end }}) (*{{ImportAlias .Output.GoIdent.GoImportPath }}. {{.Output.GoIdent.GoName }}, error) {{- if .Comments.Trailing.String }}// {{CleanComments .Comments.Trailing.String }} {{ end }}
46- {{ end }}
42+ {{.GoName }}(ctx context.Context , metadata capabilities.RequestMetadata , input *{{ImportAlias .Input.GoIdent.GoImportPath }}. {{.Input.GoIdent.GoName }} {{if ne " emptypb.Empty" (ConfigType $service )}}, {{(ConfigType $service )}}{{ end }}) (*{{ImportAlias .Output.GoIdent.GoImportPath }}. {{.Output.GoIdent.GoName }}, error)
43+ {{- end }}
4744 {{- end }}
4845
46+ {{ range Labels . }}
47+ {{.Name }}() {{.Type }}
48+ {{ end }}
49+
4950 Start(ctx context.Context ) error
5051 Close() error
5152 HealthReport() map[string]error
@@ -62,50 +63,50 @@ func New{{.GoName}}Server(capability {{.GoName}}Capability) *{{.GoName}}Server {
6263 stopCh: stopCh,
6364 }
6465}
65- {{ if .Comments.Leading.String }}//{{ .GoName }}Server {{CleanComments .Comments.Leading.String }} {{ end }}
66- type {{.GoName }}Server struct { {{- if .Comments.Trailing.String }}// {{CleanComments .Comments.Trailing.String }} {{ end }}
66+
67+ type {{.GoName }}Server struct {
6768 {{.GoName | LowerFirst}}Capability
6869 capabilityRegistry core.CapabilitiesRegistry
6970 stopCh chan struct{}
7071}
7172
7273
73- func (cs *{{.GoName }}Server) Initialise(ctx context.Context , config string, telemetryService core.TelemetryService , store core.KeyValueStore , capabilityRegistry core.CapabilitiesRegistry , errorLog core.ErrorLog , pipelineRunner core.PipelineRunnerService , relayerSet core.RelayerSet , oracleFactory core.OracleFactory , gatewayConnector core.GatewayConnector , p2pKeystore core.Keystore ) error {
74- if err := cs . {{.GoName }}Capability.Initialise (ctx, config, telemetryService, store, errorLog, pipelineRunner, relayerSet, oracleFactory, gatewayConnector, p2pKeystore); err != nil {
74+ func (c *{{.GoName }}Server) Initialise(ctx context.Context , config string, telemetryService core.TelemetryService , store core.KeyValueStore , capabilityRegistry core.CapabilitiesRegistry , errorLog core.ErrorLog , pipelineRunner core.PipelineRunnerService , relayerSet core.RelayerSet , oracleFactory core.OracleFactory , gatewayConnector core.GatewayConnector , p2pKeystore core.Keystore ) error {
75+ if err := c . {{.GoName }}Capability.Initialise (ctx, config, telemetryService, store, errorLog, pipelineRunner, relayerSet, oracleFactory, gatewayConnector, p2pKeystore); err != nil {
7576 return fmt.Errorf (" error when initializing capability: %w " , err)
7677 }
7778
78- cs .capabilityRegistry = capabilityRegistry
79+ c .capabilityRegistry = capabilityRegistry
7980
8081 if err := capabilityRegistry.Add (ctx, &{{.GoName | LowerFirst}}Capability{
81- {{.GoName }}Capability: cs . {{.GoName }}Capability,
82+ {{.GoName }}Capability: c . {{.GoName }}Capability,
8283 }); err != nil {
8384 return fmt.Errorf (" error when adding kv store action to the registry: %w " , err)
8485 }
8586
8687 return nil
8788}
8889
89- func (cs *{{.GoName }}Server) Close() error{
90+ func (c *{{.GoName }}Server) Close() error{
9091 ctx, cancel := context.WithTimeout (context.Background (), time.Second )
9192 defer cancel()
9293
93- if cs .capabilityRegistry != nil {
94- if err := cs .capabilityRegistry.Remove (ctx, " {{(CapabilityId $service)}} " ); err != nil {
94+ if c .capabilityRegistry != nil {
95+ if err := c .capabilityRegistry.Remove (ctx, {{ $fullCapabilityId }} ); err != nil {
9596 return err
9697 }
9798 }
9899
99- if cs .stopCh != nil {
100- close(cs .stopCh )
100+ if c .stopCh != nil {
101+ close(c .stopCh )
101102 }
102103
103- return cs . {{.GoName | LowerFirst}}Capability.Close ()
104+ return c . {{.GoName | LowerFirst}}Capability.Close ()
104105}
105106
106107
107- func (cs *{{.GoName }}Server) Infos(ctx context.Context ) ([]capabilities.CapabilityInfo , error) {
108- info, err := cs . {{.GoName | LowerFirst}}Capability.Info (ctx)
108+ func (c *{{.GoName }}Server) Infos(ctx context.Context ) ([]capabilities.CapabilityInfo , error) {
109+ info, err := c . {{.GoName | LowerFirst}}Capability.Info (ctx)
109110 if err != nil {
110111 return nil , err
111112 }
@@ -119,7 +120,7 @@ type {{.GoName|LowerFirst}}Capability struct {
119120
120121func (c *{{.GoName | LowerFirst}}Capability) Info(ctx context.Context ) (capabilities.CapabilityInfo , error) {
121122 // Maybe we do need to split it out, even if the user doesn't see it
122- return capabilities.NewCapabilityInfo (" {{(CapabilityId $service)}} " , capabilities.CapabilityTypeCombined , c. {{.GoName }}Capability.Description ())
123+ return capabilities.NewCapabilityInfo ({{ $fullCapabilityId }} , capabilities.CapabilityTypeCombined , c. {{.GoName }}Capability.Description ())
123124}
124125
125126
@@ -134,7 +135,7 @@ func (c *{{.GoName|LowerFirst}}Capability) RegisterTrigger(ctx context.Context,
134135 {{- if (isTrigger . ) }}
135136 case {{- if (MapToUntypedAPI . ) }} " " {{- else }} " {{.GoName}}" {{- end }}:
136137 input := &{{ImportAlias .Input.GoIdent.GoImportPath }}. {{.Input.GoIdent.GoName }}{}
137- return capabilities.RegisterTrigger (ctx, c.stopCh , " {{(CapabilityId $service)}} " , request, input, c. {{$service .GoName }}Capability.Register {{.GoName }})
138+ return capabilities.RegisterTrigger (ctx, c.stopCh , {{ $fullCapabilityId }} , request, input, c. {{$service .GoName }}Capability.Register {{.GoName }})
138139 {{- end }}
139140 {{- end }}
140141 default:
0 commit comments