Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): use nats queue subscriptions #3706

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 21 additions & 3 deletions docker-compose.nats.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
version: "3.2"
version: "3.8"
services:
traefik:
image: traefik:v2.4
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
ports:
- "11633:80" # Changed this line
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock

tracetest:
labels:
- "traefik.enable=true"
- "traefik.http.routers.tracetest.rule=Host(`localhost`)"
- "traefik.http.services.tracetest.loadbalancer.server.port=11633"
deploy:
replicas: 3
restart: unless-stopped
image: kubeshop/tracetest:${TAG:-latest}
extra_hosts:
Expand All @@ -14,8 +32,8 @@ services:
- type: bind
source: ./local-config/tracetest.provision.yaml
target: /app/provisioning.yaml
ports:
- 11633:11633
expose:
- 11633
command: --provisioning-file /app/provisioning.yaml
healthcheck:
test: ["CMD", "wget", "--spider", "localhost:11633"]
Expand Down
2 changes: 1 addition & 1 deletion server/pkg/pipeline/nats_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (d *NatsDriver[T]) Enqueue(ctx context.Context, msg T) {

// SetListener implements QueueDriver.
func (d *NatsDriver[T]) SetListener(listener Listener[T]) {
subscription, err := d.conn.Subscribe(d.topic, func(msg *nats.Msg) {
subscription, err := d.conn.QueueSubscribe(d.topic, "queue_worker", func(msg *nats.Msg) {
var target T
err := json.Unmarshal(msg.Data, &target)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion server/subscription/nats_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type natsManager struct {
}

func (m *natsManager) Subscribe(resourceID string, subscriber Subscriber) Subscription {
subscription, err := m.conn.Subscribe(resourceID, func(msg *nats.Msg) {
subscription, err := m.conn.QueueSubscribe(resourceID, "subscriptions", func(msg *nats.Msg) {
decoded, err := DecodeMessage(msg.Data)
if err != nil {
log.Printf("cannot unmarshall incoming nats message: %s", err.Error())
Expand Down