Documentation ¶
Index ¶
Constants ¶
View Source
const ReconnectDelay = 10 * time.Second
don't restart too quickly, or continuous os failures could create extreme system pressure
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Consumer ¶
type Consumer struct { sync.Mutex // embed a lock to be synced for thread safety // service pool address PoolAddr string // HBI connection to service pool PoolMaster *hbi.TCPConn // default context factory CtxFact func() hbi.HoContext // established service connections, first by proc address string, then by tunnel id string // direct access not recommended, but if so, should be synced when accessing from multiple goros SvcConns map[string]map[string]*hbi.TCPConn }
func NewConsumer ¶
func (*Consumer) AssignProc ¶
func (*Consumer) GetService ¶
func (consumer *Consumer) GetService( ctxFact func() hbi.HoContext, tunnel string, session string, sticky bool, ) (service *hbi.TCPConn, err error)
get an HBI connection to an assigned service proc by session id
func (*Consumer) ReleaseProc ¶
type StaticRegistry ¶
type StaticRegistry struct { // service address to resolve to ServiceAddr string }
embed this struct with a static service address for simplest service resolving
func (StaticRegistry) AssignProc ¶
func (reg StaticRegistry) AssignProc(session string, sticky bool) (procAddr string)
func (StaticRegistry) ReleaseProc ¶
func (reg StaticRegistry) ReleaseProc(procAddr string) (idle bool)
type WorkerHoContext ¶
type WorkerHoContext interface { hbi.HoContext // should prepare for the session and send verbatim session id string back via `PoToPeer().CoSendCode()` PrepareSession(session string) string }
A service hosting worker process should communicate with service pool master at TCP address specified as `-team`, using a context struct embedding this interface, constructed by `NewWorkerHoContext()`, and optionally implement (override) methods defined by this interface.
And once it get ready for HBI service hosting, it should tell the pool master its service port by:
ctx.Ho().Po().Notif(`WorkerOnline(<pid int>, <procPort int>)`)
func NewWorkerHoContext ¶
func NewWorkerHoContext() WorkerHoContext
Click to show internal directories.
Click to hide internal directories.