microservice

package
v0.0.0-...-461edb3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delegate

type Delegate func(m *Service, topic string, message []byte) bool

Delegate is a handler that the user can register on a certain received topic

type Message

type Message struct {
	Topic   string
	Payload []byte
}

type Service

type Service struct {
	Name            string
	Logger          *logpkg.Logger
	PubsubRegister  []string
	PubsubSubscribe []string
	Pubsub          *pubsub.Context
	Handlers        map[string]Delegate
	CatchHandler    Delegate
	ProcessMessages chan *Message
}

Service is a convenience setup to implement a micro-service

func New

func New(name string) *Service

func (*Service) FindHandler

func (m *Service) FindHandler(itopic string) (delegate Delegate, exists bool)

func (*Service) Loop

func (m *Service) Loop()

func (*Service) Register

func (m *Service) Register(r string) error

func (*Service) RegisterAndSubscribe

func (m *Service) RegisterAndSubscribe(register []string, subscribe []string)

func (*Service) RegisterHandler

func (m *Service) RegisterHandler(topic string, delegate Delegate)

func (*Service) Subscribe

func (m *Service) Subscribe(r string) error

Jump to

Keyboard shortcuts

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