...

Package router

import "golang.conradwood.net/go-easyops/router"
Overview
Index

Overview ▾

The FanoutRouter distributes work (evenly) between available instances, dynamically adjusting to instances coming and going.

fanoutrouter maintains a go-routine per instance. each go-routine listens on a channel for work. Any work received, triggers a function with a grpcConnection as parameter. The result of that function is passed to second channel. The number of go-routines changes dynamically as instances come and go. Each go-routine, if it has work to do, will call a "processor" (a user defined function) with a ProcessRequest. Once the processor completed its work, the result will be send to a function (perhaps even multi-threaded!)

type CompletionNotification

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

func (*CompletionNotification) Error

func (p *CompletionNotification) Error() error

func (*CompletionNotification) Object

func (p *CompletionNotification) Object() interface{}

type Connection

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

func (*Connection) Close

func (c *Connection) Close()

func (*Connection) GRPCConnection

func (c *Connection) GRPCConnection() (*grpc.ClientConn, error)

type ConnectionManager

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

func NewConnectionManager

func NewConnectionManager(servicename string) *ConnectionManager

func (*ConnectionManager) AllowMultipleInstancesPerIP

func (cm *ConnectionManager) AllowMultipleInstancesPerIP()

func (*ConnectionManager) GetCurrentTargets

func (cm *ConnectionManager) GetCurrentTargets(ctx context.Context) []*ConnectionTarget

func (*ConnectionManager) ServiceName

func (cm *ConnectionManager) ServiceName() string

type ConnectionTarget

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

func (*ConnectionTarget) Address

func (ct *ConnectionTarget) Address() string

func (*ConnectionTarget) Close

func (ct *ConnectionTarget) Close()

func (*ConnectionTarget) Connection

func (ct *ConnectionTarget) Connection() (*Connection, error)

type FanoutRouter

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

func NewFanoutRouter

func NewFanoutRouter(cm *ConnectionManager, processor func(*ProcessRequest) error, consumer func(*CompletionNotification)) *FanoutRouter

func (*FanoutRouter) Stop

func (fr *FanoutRouter) Stop()

this can take a long time, because we wait for all pending requests to finish before returning

func (*FanoutRouter) SubmitWork

func (fr *FanoutRouter) SubmitWork(object interface{})

type ProcessRequest

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

func (*ProcessRequest) GRPCConnection

func (p *ProcessRequest) GRPCConnection() *grpc.ClientConn

func (*ProcessRequest) Object

func (p *ProcessRequest) Object() interface{}