Version: v0.6.3 Latest Latest

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

Go to latest
Published: Jun 26, 2021 License: MIT Imports: 17 Imported by: 1




View Source
const (
	DefaultMaxSize = 4096


View Source
var (
	DefaultCodec = &codecs.MessageMsgPackCodec{}


This section is empty.


type ClientServer

type ClientServer struct {
	Addr string

	Mux             *radar.Mux
	Ctx             context.Context
	CancelFunc      context.CancelFunc
	Logger          sabuhp.Logger
	ErrGroup        *errgroup.Group
	BusRelay        *sabuhp.BusRelay
	SSEServer       *ssepub.SSEServer
	HttpServer      *serverpub.Server
	Bus             sabuhp.MessageBus
	Decoder         sabuhp.HttpDecoder
	Encoder         sabuhp.HttpEncoder
	HttpServlet     *hsocks.HttpServlet
	Upgrader        *websocket.Upgrader
	HeaderMod       sabuhp.HeaderModifications
	WebsocketConf   gorillapub.ConfigCreator
	WebsocketHeader gorillapub.ResponseHeadersFromRequest
	WebsocketServer *gorillapub.GorillaHub
	StreamBinder    *sabuhp.StreamBusRelay
	// contains filtered or unexported fields

ClientServer exists to provide a central connection point to the message bus for the client (browser, CLI app, ...etc). They will never host any functions or processing providers but exists to provide a direct and distributed (by creating horizontally scaled replicas) that allow clients to deliver requests into the underline pubsub bus which will deliver these to service servers who host nothing else but functions and processors.

func New

func New(ctx context.Context, logger sabuhp.Logger, bus sabuhp.MessageBus, mods ...Mod) *ClientServer

func (*ClientServer) Init added in v0.4.1

func (c *ClientServer) Init()

Init allows you to initialize all components for setup as calling ClientServer.Start with both initialize and start all related servers.

If you wish to use the default setup but customize to fit your needs it's your best interest to call ClientServer.Init first.

func (*ClientServer) Start

func (c *ClientServer) Start()

Start calls ClientServer.Init first then starts all related servers (http, websocket) etc.

func (*ClientServer) Wait

func (c *ClientServer) Wait() error

Wait will block till all services are closed and existed included created goroutines. You can confident use wait to block and know that once done there is zero chances of goroutine or memory leak as regards started resources.

type Mod

type Mod func(cs *ClientServer)

func WithHeaderMod added in v0.4.1

func WithHeaderMod(this sabuhp.HeaderModifications) Mod

func WithHttpAddr

func WithHttpAddr(httpAddr string) Mod

func WithHttpDecoder

func WithHttpDecoder(this sabuhp.HttpDecoder) Mod

func WithHttpEncoder

func WithHttpEncoder(this sabuhp.HttpEncoder) Mod

func WithHttpServer

func WithHttpServer(this *serverpub.Server) Mod

func WithMux

func WithMux(config radar.MuxConfig) Mod

func WithSSEServer

func WithSSEServer(this *ssepub.SSEServer) Mod

func WithWebsocketConfigCreator added in v0.4.1

func WithWebsocketConfigCreator(this gorillapub.ConfigCreator) Mod

func WithWebsocketHeader

func WithWebsocketHeader(this gorillapub.ResponseHeadersFromRequest) Mod

func WithWebsocketServer

func WithWebsocketServer(this *gorillapub.GorillaHub) Mod

func WithWebsocketUpgrader

func WithWebsocketUpgrader(this *websocket.Upgrader) Mod

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL