Skip to content

Commit

Permalink
Refactoring pub_sub
Browse files Browse the repository at this point in the history
  • Loading branch information
ihippik committed Mar 12, 2024
1 parent 80a30db commit 4b2f18c
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 21 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ As the message broker will be used is of your choice:
- NATS JetStream [`type=nats`];
- Apache Kafka [`type=kafka`];
- RabbitMQ [`type=rabbitmq`].
- Google Pub/Sub [`type=google_pubsub`].

Service publishes the following structure.
The name of the topic for subscription to receive messages is formed from the prefix of the topic,
Expand Down
3 changes: 1 addition & 2 deletions cmd/wal-listener/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ func factoryPublisher(ctx context.Context, cfg *config.PublisherCfg, logger *slo
return nil, fmt.Errorf("could not create pubsub connection: %w", err)
}

pubSubPublisher := publisher.NewGooglePubSubPublisher(pubSubConn)
return pubSubPublisher, nil
return publisher.NewGooglePubSubPublisher(pubSubConn), nil
default:
return nil, fmt.Errorf("unknown publisher type: %s", cfg.Type)
}
Expand Down
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
PublisherTypeNats PublisherType = "nats"
PublisherTypeKafka PublisherType = "kafka"
PublisherTypeRabbitMQ PublisherType = "rabbitmq"
PublisherTypeGooglePubSub PublisherType = "googlepubsub"
PublisherTypeGooglePubSub PublisherType = "google_pubsub"
)

// Config for wal-listener.
Expand Down Expand Up @@ -48,7 +48,7 @@ type PublisherCfg struct {
ClientCert string `json:"client_cert"`
ClientKey string `json:"client_key"`
CACert string `json:"ca_cert"`
PubSubProjectID string
PubSubProjectID string `json:"pubsub_project_id"`
}

// DatabaseCfg path of the PostgreSQL DB config.
Expand Down
29 changes: 28 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/ihippik/wal-listener/v2
go 1.22

require (
cloud.google.com/go/pubsub v1.37.0
github.com/IBM/sarama v1.43.0
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2
github.com/goccy/go-json v0.10.2
Expand All @@ -17,9 +18,14 @@ require (
github.com/urfave/cli/v2 v2.26.0
github.com/wagslane/go-rabbitmq v0.12.4
golang.org/x/sync v0.6.0
google.golang.org/grpc v1.62.0
)

require (
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute v1.24.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/apd v1.1.0 // indirect
Expand All @@ -28,10 +34,18 @@ require (
github.com/eapache/go-resiliency v1.6.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/getsentry/sentry-go v0.25.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
Expand Down Expand Up @@ -69,13 +83,26 @@ require (
github.com/stretchr/objx v0.5.1 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.48.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.48.0 // indirect
go.opentelemetry.io/otel v1.23.0 // indirect
go.opentelemetry.io/otel/metric v1.23.0 // indirect
go.opentelemetry.io/otel/trace v1.23.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.167.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240304161311-37d4d3c04a78 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240228224816-df926f6c8641 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 4b2f18c

Please sign in to comment.