instance_manager

package
v0.0.0-...-12a776e Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: MPL-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package instance_manager manages the instances

Package instance_manager manages the instances

Index

Constants

View Source
const (
	InstanceCreated = "created" // Instance is created, but not initialized yet. Used for child instances
	Running         = "running"
	Idle            = "idle"
)
View Source
const (
	EventClose           = "close"            // notify instance manager is starting to close
	EventIdle            = "idle"             // notify instance manager is not running but created
	EventReady           = "ready"            // notify instance manager is ready
	EventError           = "error"            // notify if in the instance manager occurred an error
	EventInstanceAdded   = "instance_added"   // notify if a new instance added
	EventInstanceDeleted = "instance_deleted" // notify if the instance is deleted
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Child

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

type Parent

type Parent struct {
	MessageOps *message.Operations
	// contains filtered or unexported fields
}

func New

func New(id string, parent *log.Logger) *Parent

New instance manager is created with the handler id

func (*Parent) AddInstance

func (parent *Parent) AddInstance(handlerType config.HandlerType, routes kvRef, routeDeps kvRef, clients kvRef) (string, error)

AddInstance to the handler. Returns generated instance id and error. Returns error if instance manager is not running. Returns error if instance client socket creation fails.

func (*Parent) Close

func (parent *Parent) Close()

Close the instance manager. It deletes all instances. The reason why it doesn't return an error is because it broadcasts them through pub socket. Also, it needs a time for closing the instance manager sockets.

func (*Parent) DeleteInstance

func (parent *Parent) DeleteInstance(instanceId string, instant bool) error

DeleteInstance closes the instance. Sends the signal to the instance thread. Instance sends back to instance manager a status update.

instanceId must be registered in the instance manager.

If instant is set true, then instance is closed without replying back

func (*Parent) Handler

func (parent *Parent) Handler(instanceId string) *zmq.Socket

Handler socket of the instance.

Don't do any operations on the socket, as it could lead to the unexpected behaviors of the instance manager.

func (*Parent) Instances

func (parent *Parent) Instances() map[string]string

Instances returns all instances as instance_id => instance_status

func (*Parent) NewInstanceId

func (parent *Parent) NewInstanceId() string

func (*Parent) Ready

func (parent *Parent) Ready() (string, *zmq.Socket)

Ready returns an instance that's ready to handle requests

func (*Parent) SetMessageOperations

func (parent *Parent) SetMessageOperations(messageOps *message.Operations)

SetMessageOperations overwrites the default message type.

func (*Parent) Start

func (parent *Parent) Start() error

Start the instance manager to receive the data from the instances Use the goroutine. The operations of the instance manager are not done via socket.

func (*Parent) Status

func (parent *Parent) Status() string

Status of the instance manager.

Jump to

Keyboard shortcuts

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