strongforce

package module
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 13 Imported by: 0

README


Logo

Strongforce

Create highly consistent microservice architectures
Explore the docs »

View Demo · Report Bug · Request Feature

About The Project

Create highly consistent microservice architectures using the outbox pattern combined with the NATS eventing platform.

Getting Started

TODO

Prerequisites

TODO

Usage

Subscribing

Declare the handlers of a subscription with bus.Handle. The consumer only receives the subjects it has handlers for, and the payload is decoded into the handler's event type:

sub, err := sf.Bus().Subscribe(ctx, "incidents", "tasks",
	bus.WithDurable(),
	bus.Handle("tasks.v1.task.updated.assignee", handleTaskAssigned),
)
if err != nil {
	return err
}
sub.Start(ctx)

func handleTaskAssigned(ctx context.Context, event *eventsv1.TaskAssignedEvent, msg bus.InboundMessage) error {
	// ...
}

A handler settles its message by what it returns:

Return Outcome
nil acked
bus.Skip("incident %s was deleted", id) acked, logged and counted as skipped
any other error retried with exponential backoff, dead-lettered once the attempts are used up
bus.Permanent(err) dead-lettered right away; undecodable payloads are permanent

Handlers run with a deadline of nine tenths of the consumer's AckWait, so the broker does not redeliver a message that is still being handled. Raise it with bus.WithAckWait for slow handlers.

nats.Options.Middleware wraps the handlers of every subscription of a bus, e.g. to prepare the handler context. Handler tests build messages with bustest.Message(id, subject).

Contribution guide

Guidelines

  • Use conventional commit messages
  • Always create a PR against the dev branch
  • Use the pre-commit tool to verify your code before committing

Setup pre-commit hooks

brew install pre-commit
pre-commit install

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoDB  = errors.New("no database configured")
	ErrNoBus = errors.New("no bus configured")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (*Client, error)

func (*Client) Bus

func (sf *Client) Bus() bus.Bus

func (*Client) DB

func (sf *Client) DB() db.DB

func (*Client) EventBuilder

func (sf *Client) EventBuilder() *events.Builder

func (*Client) Init

func (sf *Client) Init() error

func (*Client) TestHelper added in v0.14.0

func (sf *Client) TestHelper() *testhelper.TestHelper

type Option

type Option func(o *clientOptions)

func WithDebeziumForwarder added in v0.16.0

func WithDebeziumForwarder(options *forwarder.DebeziumOptions) Option

func WithForwarder

func WithForwarder(options *forwarder.Options) Option

func WithLogger

func WithLogger(logger *zap.Logger) Option

func WithMySQL

func WithMySQL(options *mysql.Options) Option

func WithNATS

func WithNATS(options *nats.Options) Option

func WithPostgres

func WithPostgres(options *postgres.Options) Option

type Options

type Options struct {
	DB     db.DB
	Bus    bus.Bus
	Logger *zap.Logger
}

Directories

Path Synopsis
examples
bus command
postgres command
pkg
bus
bus/bustest
Package bustest builds bus messages for handler tests.
Package bustest builds bus messages for handler tests.
db
protobuf
tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL