Skip to content

Commit 1ca1504

Browse files
committed
refactor: remove unused eventBus and registry fields from link_cqrs.Service
- Remove unused eventBus and registry fields from link_cqrs.Service struct - Update New() function signature to remove unused parameters - Regenerate wire_gen.go with updated dependencies - Remove migration documentation files (MIGRATION-PLAN-CQRS.md, CQRS-PACKAGE-ANALYSIS.md) - Update ADR-0041 to remove references to deleted migration files This completes the cleanup phase of CQRS migration by removing unused dependencies that were no longer needed after the migration to go-sdk/cqrs.
1 parent 0bc4ffc commit 1ca1504

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3557
-673
lines changed

boundaries/link/go.mod

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/shortlink-org/shortlink/boundaries/link
33
go 1.25.4
44

55
require (
6+
github.com/IBM/sarama v1.46.3
67
github.com/Masterminds/squirrel v1.5.5-0.20240227163215-1ded5784535d
78
github.com/ThreeDotsLabs/watermill v1.5.1
89
github.com/authzed/authzed-go v1.7.0
@@ -23,22 +24,22 @@ require (
2324
github.com/shortlink-org/go-sdk/cache v0.0.0-20251125204117-ffa44b328293
2425
github.com/shortlink-org/go-sdk/config v0.0.0-20251125204117-ffa44b328293
2526
github.com/shortlink-org/go-sdk/context v0.0.0-20251125204117-ffa44b328293
27+
github.com/shortlink-org/go-sdk/cqrs v0.0.0-20251125223100-c627280ca6e5
2628
github.com/shortlink-org/go-sdk/db v0.0.0-20251125204117-ffa44b328293
2729
github.com/shortlink-org/go-sdk/flags v0.0.0-20251125204117-ffa44b328293
2830
github.com/shortlink-org/go-sdk/flight_trace v0.0.0-20251125204117-ffa44b328293
2931
github.com/shortlink-org/go-sdk/graceful_shutdown v0.0.0-20251125204117-ffa44b328293
3032
github.com/shortlink-org/go-sdk/grpc v0.0.0-20251125204117-ffa44b328293
3133
github.com/shortlink-org/go-sdk/http v0.0.0-20251125204117-ffa44b328293
3234
github.com/shortlink-org/go-sdk/logger v0.0.0-20251125204117-ffa44b328293
33-
github.com/shortlink-org/go-sdk/mq v0.0.0-20251125204117-ffa44b328293
34-
github.com/shortlink-org/go-sdk/notify v0.0.0-20251125204117-ffa44b328293
3535
github.com/shortlink-org/go-sdk/observability v0.0.0-20251125204117-ffa44b328293
3636
github.com/shortlink-org/go-sdk/saga v0.0.0-20251125204117-ffa44b328293
37-
github.com/shortlink-org/go-sdk/watermill v0.0.0-20251125204117-ffa44b328293
37+
github.com/shortlink-org/go-sdk/watermill v0.0.0-20251125223100-c627280ca6e5
3838
github.com/spf13/viper v1.21.0
3939
github.com/stretchr/testify v1.11.1
4040
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d
4141
github.com/testcontainers/testcontainers-go v0.40.0
42+
github.com/testcontainers/testcontainers-go/modules/kafka v0.40.0
4243
github.com/testcontainers/testcontainers-go/modules/mongodb v0.40.0
4344
github.com/testcontainers/testcontainers-go/modules/mysql v0.40.0
4445
github.com/testcontainers/testcontainers-go/modules/postgres v0.40.0
@@ -60,7 +61,6 @@ require (
6061
dario.cat/mergo v1.0.2 // indirect
6162
filippo.io/edwards25519 v1.1.0 // indirect
6263
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
63-
github.com/IBM/sarama v1.46.3 // indirect
6464
github.com/Masterminds/semver/v3 v3.4.0 // indirect
6565
github.com/Microsoft/go-winio v0.6.2 // indirect
6666
github.com/Unleash/unleash-go-sdk/v5 v5.0.3 // indirect
@@ -145,9 +145,6 @@ require (
145145
github.com/montanaflynn/stats v0.7.1 // indirect
146146
github.com/morikuni/aec v1.0.0 // indirect
147147
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
148-
github.com/nats-io/nats.go v1.47.0 // indirect
149-
github.com/nats-io/nkeys v0.4.12 // indirect
150-
github.com/nats-io/nuid v1.0.1 // indirect
151148
github.com/ncruces/go-strftime v0.1.9 // indirect
152149
github.com/neo4j/neo4j-go-driver/v5 v5.28.4 // indirect
153150
github.com/oklog/ulid v1.3.1 // indirect
@@ -171,7 +168,6 @@ require (
171168
github.com/prometheus/common v0.67.4 // indirect
172169
github.com/prometheus/otlptranslator v1.0.0 // indirect
173170
github.com/prometheus/procfs v0.19.2 // indirect
174-
github.com/rabbitmq/amqp091-go v1.10.0 // indirect
175171
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect
176172
github.com/redis/go-redis/v9 v9.17.0 // indirect
177173
github.com/redis/rueidis/rueidiscompat v1.0.68 // indirect

boundaries/link/go.sum

Lines changed: 4 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

boundaries/link/internal/di/wire.go

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ package link_di
1111
import (
1212
"context"
1313

14-
"github.com/ThreeDotsLabs/watermill/message"
1514
"github.com/authzed/authzed-go/v1"
1615
"github.com/google/wire"
1716
shortctx "github.com/shortlink-org/go-sdk/context"
17+
"github.com/shortlink-org/go-sdk/cqrs/bus"
18+
cqrsmessage "github.com/shortlink-org/go-sdk/cqrs/message"
1819
"github.com/shortlink-org/go-sdk/flags"
1920
"github.com/shortlink-org/go-sdk/flight_trace"
2021
"github.com/shortlink-org/go-sdk/logger"
@@ -24,10 +25,11 @@ import (
2425
"go.opentelemetry.io/otel/trace"
2526
"google.golang.org/grpc"
2627

28+
cqrs_registry "github.com/shortlink-org/shortlink/boundaries/link/internal/infrastructure/cqrs"
2729
"github.com/shortlink-org/shortlink/boundaries/link/internal/infrastructure/repository/cqrs/cqs"
2830
"github.com/shortlink-org/shortlink/boundaries/link/internal/infrastructure/repository/cqrs/query"
2931
"github.com/shortlink-org/shortlink/boundaries/link/internal/infrastructure/repository/crud"
30-
cqrs "github.com/shortlink-org/shortlink/boundaries/link/internal/infrastructure/rpc/cqrs/link/v1"
32+
cqrs_rpc "github.com/shortlink-org/shortlink/boundaries/link/internal/infrastructure/rpc/cqrs/link/v1"
3133
link_rpc "github.com/shortlink-org/shortlink/boundaries/link/internal/infrastructure/rpc/link/v1"
3234
"github.com/shortlink-org/shortlink/boundaries/link/internal/infrastructure/rpc/run"
3335
sitemap_rpc "github.com/shortlink-org/shortlink/boundaries/link/internal/infrastructure/rpc/sitemap/v1"
@@ -63,7 +65,7 @@ type LinkService struct {
6365
// Delivery
6466
run *run.Response
6567
linkRPCServer *link_rpc.LinkRPC
66-
linkCQRSRPCServer *cqrs.LinkRPC
68+
linkCQRSRPCServer *cqrs_rpc.LinkRPC
6769
sitemapRPCServer *sitemap_rpc.Sitemap
6870

6971
// Application
@@ -92,6 +94,24 @@ var DefaultSet = wire.NewSet(
9294
flight_trace.New,
9395
)
9496

97+
// CQRSSet =============================================================================================================
98+
// CQRS wire set for event-driven architecture components
99+
// Provides: EventRegistry, ShortlinkNamer, ProtoMarshaler, EventBus, CommandBus
100+
// Requires: message.Publisher (from watermill.Client)
101+
// Note: ShortlinkNamer is a singleton to ensure consistent naming across all components
102+
var CQRSSet = wire.NewSet(
103+
// CQRS Registry and Namer (singleton)
104+
cqrs_registry.NewEventRegistry,
105+
cqrs_registry.NewShortlinkNamer,
106+
// ProtoMarshaler (depends on namer)
107+
cqrs_registry.NewProtoMarshaler,
108+
// Bind concrete ProtoMarshaler to Marshaler interface
109+
wire.Bind(new(cqrsmessage.Marshaler), new(*cqrsmessage.ProtoMarshaler)),
110+
// EventBus and CommandBus (depend on namer and marshaler)
111+
cqrs_registry.NewEventBus,
112+
cqrs_registry.NewCommandBus,
113+
)
114+
95115
// LinkService =========================================================================================================
96116
var LinkSet = wire.NewSet(
97117
// Common
@@ -106,17 +126,20 @@ var LinkSet = wire.NewSet(
106126
watermill_kafka.New,
107127
wire.Value([]watermill.Option{}),
108128
watermill.New,
109-
wire.FieldsOf(new(*watermill.Client), "Publisher"),
129+
wire.FieldsOf(new(*watermill.Client), "Publisher", "Subscriber"),
110130
rpc.InitServer,
111131
NewRPCClient,
112132
link_rpc.New,
113-
cqrs.New,
133+
cqrs_rpc.New,
114134
sitemap_rpc.New,
115135
NewRunRPCServer,
116136

117137
link_rpc.NewLinkServiceClient,
118138
// metadata_rpc.NewMetadataServiceClient,
119139

140+
// CQRS (using CQRSSet)
141+
CQRSSet,
142+
120143
// Applications
121144
NewLinkApplication,
122145
link_cqrs.New,
@@ -154,21 +177,26 @@ func NewRPCClient(
154177
return runRPCClient, cleanup, nil
155178
}
156179

157-
func NewLinkApplication(log logger.Logger, publisher message.Publisher, store *crud.Store, authPermission *authzed.Client) (*link.UC, error) {
158-
linkService, err := link.New(log, publisher, nil, store, authPermission)
180+
func NewLinkApplication(
181+
log logger.Logger,
182+
eventBus *bus.EventBus,
183+
store *crud.Store,
184+
authPermission *authzed.Client,
185+
) (*link.UC, error) {
186+
linkService, err := link.New(log, nil, store, authPermission, eventBus)
159187
if err != nil {
160188
return nil, err
161189
}
162190

163191
return linkService, nil
164192
}
165193

166-
func NewSitemapService(log logger.Logger, publisher message.Publisher) (*sitemap.Service, error) {
167-
return sitemap.New(log, publisher)
194+
func NewSitemapService(log logger.Logger, eventBus *bus.EventBus) (*sitemap.Service, error) {
195+
return sitemap.New(log, eventBus)
168196
}
169197

170198
// TODO: refactoring. maybe drop this function
171-
func NewRunRPCServer(runRPCServer *rpc.Server, _ *cqrs.LinkRPC, _ *link_rpc.LinkRPC) (*run.Response, error) {
199+
func NewRunRPCServer(runRPCServer *rpc.Server, _ *cqrs_rpc.LinkRPC, _ *link_rpc.LinkRPC) (*run.Response, error) {
172200
return run.Run(runRPCServer)
173201
}
174202

@@ -194,7 +222,7 @@ func NewLinkService(
194222
// Delivery
195223
run *run.Response,
196224
linkRPCServer *link_rpc.LinkRPC,
197-
linkCQRSRPCServer *cqrs.LinkRPC,
225+
linkCQRSRPCServer *cqrs_rpc.LinkRPC,
198226
sitemapRPCServer *sitemap_rpc.Sitemap,
199227

200228
// Repository

boundaries/link/internal/di/wire_gen.go

Lines changed: 36 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

boundaries/link/internal/domain/link/v1/event.go

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)