Skip to content

Commit 42d8530

Browse files
committed
style(nats): update comments formatting and add blank lines for clarity
refactor(nats): remove unused replaceDots function to clean up code refactor(nats): change context parameter to blank identifier in connect, ensureStream, and ensureConsumer methods to indicate unused parameter
1 parent 2fb98fe commit 42d8530

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

backend/nats/bus.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var (
2626

2727
// EventBus is an event bus that uses NATS to publish and subscribe to events.
2828
//
29-
// Drivers
29+
// # Drivers
3030
//
3131
// The event bus supports both NATS Core and NATS JetStream. By default, the
3232
// Core driver is used, but you can create and specify the JetStream driver with
@@ -81,6 +81,7 @@ type envelope struct {
8181
//
8282
// If no other specified, the returned event bus will use the NATS Core Driver.
8383
// To use the NATS JetStream Driver instead, explicitly set the Driver:
84+
//
8485
// NewEventBus(enc, Use(JetStream()))
8586
func NewEventBus(enc codec.Encoding, opts ...EventBusOption) *EventBus {
8687
if enc == nil {
@@ -122,7 +123,7 @@ func (bus *EventBus) Connect(ctx context.Context) error {
122123
return err
123124
}
124125

125-
func (bus *EventBus) connect(ctx context.Context) error {
126+
func (bus *EventBus) connect(_ context.Context) error {
126127
// *nats.Conn provided via Conn() option.
127128
if bus.conn != nil {
128129
return nil

backend/nats/internal.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ var replacer = strings.NewReplacer(
99
// " ", "_",
1010
)
1111

12-
func replaceDots(s string) string {
13-
return strings.ReplaceAll(s, ".", "_")
14-
}
15-
1612
func subscribeSubject(userProvidedSubject, event string) string {
1713
if event == "*" {
1814
return ">"

backend/nats/jetstream.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func DurableFunc(fn func(event, queue string) string) JetStreamOption {
6464

6565
// Durable returns an option that makes JetStream consumers / subscriptions
6666
// durable (see DurableFunc). The durable name is formatted like this:
67+
//
6768
// fmt.Sprintf("%s:%s:%s", prefix, queue, event)
6869
func Durable(prefix string) JetStreamOption {
6970
return DurableFunc(func(event, queue string) string {
@@ -278,7 +279,7 @@ func (js *jetStream) publish(ctx context.Context, bus *EventBus, evt event.Event
278279
return nil
279280
}
280281

281-
func (js *jetStream) ensureStream(ctx context.Context) error {
282+
func (js *jetStream) ensureStream(_ context.Context) error {
282283
info, err := js.ctx.StreamInfo(js.stream)
283284
if err == nil {
284285
if info.Config.Name != js.stream {
@@ -308,7 +309,7 @@ func (js *jetStream) ensureStream(ctx context.Context) error {
308309
return nil
309310
}
310311

311-
func (js *jetStream) ensureConsumer(ctx context.Context, bus *EventBus, name, eventName, subject, queue string) error {
312+
func (js *jetStream) ensureConsumer(_ context.Context, bus *EventBus, name, eventName, subject, queue string) error {
312313
if info, err := js.ctx.ConsumerInfo(js.stream, name); err == nil {
313314
if info.Stream != js.stream {
314315
return fmt.Errorf("%w: stream name mismatch: %q != %q", ErrConsumerExists, info.Stream, js.stream)

go.work.sum

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
cel.dev/expr v0.23.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw=
2+
cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg=
3+
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.27.0/go.mod h1:yAZHSGnqScoU556rBOVkwLze6WP5N+U11RHuWaGVxwY=
4+
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
5+
github.com/cncf/xds/go v0.0.0-20250326154945-ae57f3c0d45f/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
6+
github.com/envoyproxy/go-control-plane v0.13.4/go.mod h1:kDfuBlDVsSj2MjrLEtRWtHlsWIFcGyB2RMO44Dc5GZA=
7+
github.com/envoyproxy/go-control-plane/envoy v1.32.4/go.mod h1:Gzjc5k8JcJswLjAx1Zm+wSYE20UrLtt7JZMWiWQXQEw=
8+
github.com/envoyproxy/go-control-plane/ratelimit v0.1.0/go.mod h1:Wk+tMFAFbCXaJPzVVHnPgRKdUdwW/KdbRt94AzgRee4=
9+
github.com/envoyproxy/protoc-gen-validate v1.2.1/go.mod h1:d/C80l/jxXLdfEIhX1W2TmLfsJ31lvEjwamM4DxlWXU=
10+
github.com/go-jose/go-jose/v4 v4.0.5/go.mod h1:s3P1lRrkT8igV8D9OjyL4WRyHvjB6a4JSllnOrmmBOA=
11+
github.com/golang/glog v1.2.4/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
12+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
13+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
14+
github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0=
15+
github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A=
16+
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
17+
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8=
18+
github.com/spiffe/go-spiffe/v2 v2.5.0/go.mod h1:P+NxobPc6wXhVtINNtFjNWGBTreew1GBUCwT2wPmb7g=
19+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
20+
github.com/zeebo/errs v1.4.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4=
21+
go.opentelemetry.io/contrib/detectors/gcp v1.35.0/go.mod h1:qGWP8/+ILwMRIUf9uIVLloR1uo5ZYAslM4O6OqUi1DA=
22+
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
23+
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
24+
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
25+
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
26+
golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
27+
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
28+
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
29+
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
30+
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
31+
golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw=
32+
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
33+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
34+
google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463/go.mod h1:U90ffi8eUL9MwPcrJylN5+Mk2v3vuPDptd5yyNUiRR8=

0 commit comments

Comments
 (0)