foreman

package module
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 9 Imported by: 5

README

go-foreman codecov

Foreman

logo

What is Foreman? A library that helps you build an event driven application by handling all the complexity of decoding, routing, dispatching and executing commands or subscribing for events. By having Publish/Subscribe and MessageBus patterns you could build different components on top for various architecture approaches like orchestrated sagas or workflows.

Pub/Sub features:

  • configurable pool of workers for concurrent processing, high throughput
  • graceful shutdown
  • dynamic encoding/decoding of data structs
  • message dispatcher
  • transport interface: AMQP implementation

Architecture breakdown

Getting started

Saga Component

Orchestrated sagas:

  • workflow as code
  • compensate & recover triggers
  • saga store: mysql/pg
  • history of events
  • embed sagas as subtasks of parent saga
  • HTTP API dashboard

Roadmap:

  1. Apache Kafka transport
  2. protobuf message encoder

License:

The MIT License (MIT). Please see LICENSE for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component interface {
	Init(b *MessageBus) error
}

Component allow to wrap and prepare booting of your component, which will be initialized by MessageBus

type ConfigOption

type ConfigOption func(o *container)

ConfigOption allows to configure MessageBus's container

func WithComponents

func WithComponents(components ...Component) ConfigOption

WithComponents specifies a list of additional components you want to be registered in MessageBus

func WithDispatcher

func WithDispatcher(dispatcher dispatcher.Dispatcher) ConfigOption

WithDispatcher allows to provide another dispatcher.Dispatcher implementation

func WithMessageExecutionFactory

func WithMessageExecutionFactory(factory execution.MessageExecutionCtxFactory) ConfigOption

WithMessageExecutionFactory allows to provide own execution.MessageExecutionCtxFactory

func WithRouter

func WithRouter(router endpoint.Router) ConfigOption

WithRouter allows to provide another endpoint.Router implementation

type MessageBus

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

MessageBus is a main component, kind of a container which aggregates other components

func NewMessageBus

func NewMessageBus(logger log.Logger, msgMarshaller message.Marshaller, scheme scheme.KnownTypesRegistry, subscriberOption SubscriberOption, configOpts ...ConfigOption) (*MessageBus, error)

NewMessageBus constructs MessageBus, allows to specify logger, choose subscriber or use default with transport and other options which configure implementations of other important parts

func (*MessageBus) Dispatcher

func (b *MessageBus) Dispatcher() dispatcher.Dispatcher

Dispatcher returns an instance of dispatcher.Dispatcher

func (*MessageBus) Logger

func (b *MessageBus) Logger() log.Logger

Logger returns an instance of logger

func (*MessageBus) Marshaller

func (b *MessageBus) Marshaller() message.Marshaller

func (*MessageBus) Router

func (b *MessageBus) Router() endpoint.Router

Router returns an instance of endpoint.Router

func (*MessageBus) SchemeRegistry

func (b *MessageBus) SchemeRegistry() scheme.KnownTypesRegistry

SchemeRegistry returns an instance of current scheme.KnownTypesRegistry which should contain all the types of commands and events MB works with

func (*MessageBus) Subscriber

func (b *MessageBus) Subscriber() subscriber.Subscriber

Subscriber returns an instance of subscriber.Subscriber which controls the main flow of messages

type SubscriberFactory

type SubscriberFactory func(processor subscriber.Processor, marshaller message.Marshaller) subscriber.Subscriber

SubscriberFactory is a function which gives you an access to default Processor and message.Decoder, these are needed when you implement own Subscriber

type SubscriberOption

type SubscriberOption func(subscriberOpts *subscriberOpts, c *subscriberContainer)

SubscriberOption allows to provide a few options for configuring Subscriber

func DefaultSubscriber

func DefaultSubscriber(transport transport.Transport, opts ...subscriber.Opt) SubscriberOption

DefaultSubscriber option allows to specify your own transport which will be used in the default subscriber

func WithSubscriber

func WithSubscriber(subscriber subscriber.Subscriber) SubscriberOption

WithSubscriber option allows to specify your own implementation of Subscriber for MessageBus

func WithSubscriberFactory

func WithSubscriberFactory(factory SubscriberFactory) SubscriberOption

WithSubscriberFactory provides a way to construct your own Subscriber and pass it along to MessageBus

Directories

Path Synopsis
pubsub
runtime
sql
testing
log
mocks
Package foreman is a generated GoMock package.
Package foreman is a generated GoMock package.
mocks/log
Package log is a generated GoMock package.
Package log is a generated GoMock package.
mocks/pubsub/dispatcher
Package dispatcher is a generated GoMock package.
Package dispatcher is a generated GoMock package.
mocks/pubsub/endpoint
Package endpoint is a generated GoMock package.
Package endpoint is a generated GoMock package.
mocks/pubsub/message
Package message is a generated GoMock package.
Package message is a generated GoMock package.
mocks/pubsub/message/execution
Package execution is a generated GoMock package.
Package execution is a generated GoMock package.
mocks/pubsub/subscriber
Package subscriber is a generated GoMock package.
Package subscriber is a generated GoMock package.
mocks/pubsub/transport
Package transport is a generated GoMock package.
Package transport is a generated GoMock package.
mocks/saga
Package saga is a generated GoMock package.
Package saga is a generated GoMock package.
mocks/saga/mutex
Package mutex is a generated GoMock package.
Package mutex is a generated GoMock package.

Jump to

Keyboard shortcuts

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