Skip to content

Commit

Permalink
mutation template changes for relocated code (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlowellwofford authored Apr 20, 2021
1 parent f767f19 commit 8ab4c69
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion generators/templates/module/template.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (mod *{{ .Name }}) Init(a types.ModuleAPIClient) {
{{ end }}
// TODO: You should set these mutation handlers to real functions
{{- range $name, $mutation := .Mutations }}
mutations["{{- $name }}"].handler = hNotImplemented
mutations["{{- $name }}"].Handler = hNotImplemented
{{- end }}
// TODO: You may need to initialize more things here
Log(DEBUG, "initialized")
Expand Down
9 changes: 3 additions & 6 deletions generators/templates/module/template.mod.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
package {{ .PackageName }}

import (
fmt "fmt"
"reflect"
"time"

proto "github.com/gogo/protobuf/proto"
{{- if .WithConfig }}
ptypes "github.com/gogo/protobuf/types"
{{ end }}
Expand Down Expand Up @@ -193,8 +190,8 @@ func (mod *{{- .Name }}) handleMutation(m types.Event) {
case core.MutationEvent_MUTATE:
mid := me.Mutation[1]
if mdef, ok := mutations[mid]; ok {
if mdef.handler != nil {
mdef.handler(mid, me.NodeCfg, me.NodeDsc)
if mdef.Handler != nil {
mdef.Handler(mid, me.NodeCfg, me.NodeDsc)
} else {
Logf(ERROR, "hanlder for mutation %s is nil", mid)
}
Expand Down Expand Up @@ -224,7 +221,7 @@ func init() {
}
muts[mid] = mut
// add mutators to discoverables
for url := range mdef.mutates {
for url := range mdef.Mutates {
discoveries = append(discoveries, url)
}
}
Expand Down
Loading

0 comments on commit 8ab4c69

Please sign in to comment.