Skip to content

Commit 3eaddc1

Browse files
committed
export nats conn
1 parent cec77ed commit 3eaddc1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

template.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const timeout = time.Second * {{ .Timeout }}
9797
9898
type {{ $handlerName }} struct {
9999
Server {{ $serverName }}
100-
nc *nats.Conn
100+
NatsConn *nats.Conn
101101
runners []*autonats.Runner
102102
}
103103
@@ -107,7 +107,7 @@ const timeout = time.Second * {{ .Timeout }}
107107
108108
{{- range $index, $method := $srv.Methods }}
109109
{{- $subject := subject $srv $method }}
110-
if runner, err := autonats.StartRunner(ctx, h.nc, "{{ $subject }}", "autonats", {{ $method.HandlerConcurrency }}, func(msg *nats.Msg) {
110+
if runner, err := autonats.StartRunner(ctx, h.NatsConn, "{{ $subject }}", "autonats", {{ $method.HandlerConcurrency }}, func(msg *nats.Msg) {
111111
t := not.NewTraceMsg(msg)
112112
sc, err := tracer.Extract(opentracing.Binary, t)
113113
if err != nil {
@@ -202,11 +202,11 @@ const timeout = time.Second * {{ .Timeout }}
202202
func New{{ $srv.Name }}Handler(server {{ $serverName }}, nc *nats.Conn) autonats.Handler {
203203
return &{{ $handlerName }}{
204204
Server: server,
205-
nc: nc,
205+
NatsConn: nc,
206206
}
207207
}
208208
209-
type {{ $clientName }} struct { nc *nats.Conn }
209+
type {{ $clientName }} struct { NatsConn *nats.Conn }
210210
211211
{{ range $index, $method := .Methods }}
212212
func (client *{{ $clientName }}) {{ $method.Name }}({{ template "params" $method }}) {{ template "results" $method }} {
@@ -264,7 +264,7 @@ const timeout = time.Second * {{ .Timeout }}
264264
defer cancelFn()
265265
266266
var replyMsg *nats.Msg
267-
if replyMsg, err = client.nc.RequestWithContext(ctx, "{{ $subject }}", t.Bytes()); err != nil {
267+
if replyMsg, err = client.NatsConn.RequestWithContext(ctx, "{{ $subject }}", t.Bytes()); err != nil {
268268
reqSpan.LogFields(log.Error(err))
269269
return {{ $nilResult }} err
270270
}

0 commit comments

Comments
 (0)