srvbus

package module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2022 License: GPL-3.0 Imports: 9 Imported by: 2

README

srvbus is a serice bus which united of funcitonality of three servers: EventServer, MessageServer and SerivceServer.

Introduction

Service Bus is the Service Provider for the complex project gobpm -- the BPMN v2. compliant run-time engine on Go.

srvbus provides an event service, e messaging service and an external services invokation service through its EventServer, MessageServer and ServiceServer. All three services could be used separately but their combining could simplify the task solving. For example, instead of checking if a topic is created on the EventServer, the user could subscribe on NEW_TOPIC_EVT event to catch a moment of the creation without ineffective topics list pooling.

As it mentioned before, srvbus was written to support the GoBpm project -- BPM-engine for executing BPMN v2.0 comply business processes. Meantime srvbus is a standalone package which could be used in projects demanding light, in-memory and gRPC-enabling services.

There are a lot of effective and robust services with similar or higher functionality, written by other teams, but I need to lower the complexity level on my GoBpm development.

Now I have simple, functional and robust services with minimal dependencies and minimal footprint. In case I will need more functionality, I could use these service providers as a proxy for more complex, enterprise-ready services.

Service Bus

Service Bus combines three services, provided by EventServer, MessageServer and ServiceServer.

On ServiceBus creation all three servers are created and ready for running.

Start and stop the ServiceBus

To run the ServiceBus, Run function of the srvbus package should be called.

To stop the service bus, cancel function of the context used in Run invokation should be used. There is no another way to stop the service bus and underlaying servers.

Accesing to Servers

Service Bus does not provide services of underlayed servers by itself. It just give an acces to the servers by methods GetEventServer, GetMessageServer and GetServiceServer. After getting the pointer to a desired server, the user could call the server's methods.

gRPC interface

ServerBus has a gRPC interface handler, which could be accessed from sbgrpc package. User could create a handler by package's New function and then run it.

The gRPC handler provides three rpc-s:

rpc GetMessageServer( ServerRequest ) returns ( ServerResponse ) {}

rpc GetEventServer( ServerRequest ) returns ( ServerResponse ) {}

rpc GetServiceServer( ServerRequest ) returns ( ServerResponse ) {}

All of them return a gRPC hadler of desired service.

Documentation

Overview

Package srvbus united three servers:

  • EventServer -- in-memory pub/sub event server

  • MessageServer -- in-memory message server

  • ServiceServer -- in-memory services executor

Theese servers implemented simple functionality which are just enough as for BMPN processes and as for many other cases. They are not the best in their segment, but could simplify interfaces, needed BMPN engine and other services.const. If there is necessity to use another enterprise-grade server in particular area, these servers could provide a proxy interface to use them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SBusErr added in v0.4.0

type SBusErr struct {
	Err error
	// contains filtered or unexported fields
}

func (SBusErr) Error added in v0.4.0

func (sbErr SBusErr) Error() string

type ServiceBus

type ServiceBus struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(id uuid.UUID, log *zap.SugaredLogger) (*ServiceBus, error)

func (*ServiceBus) EmitEvent added in v0.4.0

func (sb *ServiceBus) EmitEvent(name, descr string)

emits single event into the internal event server topic if the Event Server was given on New call.

func (*ServiceBus) GetEventServer added in v0.4.0

func (sb *ServiceBus) GetEventServer() (*es.EventServer, error)

func (*ServiceBus) GetMessageServer added in v0.4.0

func (sb *ServiceBus) GetMessageServer() (*ms.MessageServer, error)

func (*ServiceBus) GetServiceServer added in v0.4.0

func (sb *ServiceBus) GetServiceServer() (*s2.ServiceServer, error)

func (*ServiceBus) ID

func (sb *ServiceBus) ID() uuid.UUID

func (*ServiceBus) IsRunned

func (sb *ServiceBus) IsRunned() bool

func (*ServiceBus) Logger added in v0.4.0

func (sb *ServiceBus) Logger() *zap.SugaredLogger

func (*ServiceBus) Run

func (sb *ServiceBus) Run(ctx context.Context) error

Directories

Path Synopsis
api
Package es is a part of the srvbus package.
Package es is a part of the srvbus package.
examples
s2
internal
ds
Package ms is a part of srvbus package.
Package ms is a part of srvbus package.
proto
Package s2 is a part of the srvbus package.
Package s2 is a part of the srvbus package.

Jump to

Keyboard shortcuts

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