askill
go-messaging

go-messagingSafety 95Repository

Cloud-agnostic asynchronous messaging with abstract interfaces and implementations for NATS, RabbitMQ, and Google Pub/Sub. Trigger: When implementing event-driven communication, publishing domain events, or creating event subscribers.

0 stars
1.2k downloads
Updated 2/9/2026

Package Files

Loading files...
SKILL.md

When to Use

  • Publishing domain events after state changes
  • Subscribing to events from other services
  • Choosing a messaging backend for the project
  • Implementing async workflows (notifications, emails, analytics)

Critical Patterns

PatternRule
Interface in domainEventPublisher is a domain port
Implementation swappableNATS, RabbitMQ, or Pub/Sub behind same interface
Events are immutable factsPast tense: BookingCreated, PaymentCompleted
Events carry dataInclude enough data so consumers don't need to call back
Idempotent consumersSubscribers MUST handle duplicate messages
Cloud agnosticApplication layer never imports messaging SDK

Event Definition (Domain)

Reference: assets/event.go

Domain Port

Reference: assets/port.go

NATS Implementation

Reference: assets/nats_publisher.go

Reference: assets/nats_subscriber.go

Topic Naming Convention

{service}.{domain}.{event}

Examples:
  booking.booking.created
  booking.booking.cancelled
  payment.transaction.completed
  caregiver.profile.verified
  notification.email.requested

Publishing from Application Layer

Reference: assets/publish_usage.go

In-Memory Implementation (Testing)

Reference: assets/memory_publisher.go

Commands

# NATS
brew install nats-server
nats-server  # Start locally

# Dependencies
go get github.com/nats-io/nats.go

# RabbitMQ alternative
docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:management
go get github.com/rabbitmq/amqp091-go

Anti-Patterns

❌ Don't✅ Do
Import NATS/RabbitMQ in domainDefine EventPublisher interface in domain
Events named as commands (CreateBooking)Events are past tense facts (BookingCreated)
Consumer calls back to producer serviceInclude enough data in the event payload
Assume exactly-once deliveryDesign idempotent consumers
Synchronous event publishing blocking the requestUse goroutines or accept best-effort for non-critical events

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

78/100Analyzed 2/20/2026

Well-structured technical reference skill for Go messaging patterns with cloud-agnostic design. Covers NATS, RabbitMQ, and Pub/Sub implementations with clear patterns, naming conventions, and anti-patterns. Lacks actual code implementation details but provides solid architectural guidance. Located in proper skills folder with good metadata and tags.

95
88
88
72
65

Metadata

Licenseunknown
Version-
Updated2/9/2026
Publisher333-333-333

Tags

github