config

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: 4 Imported by: 13

Documentation

Index

Constants

View Source
const (
	HandlerStatus  = "status"
	ClosePart      = "close_part"
	RunPart        = "run-part"
	InstanceAmount = "instance-amount"
	MessageAmount  = "message-amount"
	AddInstance    = "add-instance"
	DeleteInstance = "delete-instance"
	Parts          = "parts"
	HandlerClose   = "close"  // Close the handler
	HandlerConfig  = "config" // Returns the handler configuration
)

Variables

This section is empty.

Functions

func CanReply

func CanReply(handlerType HandlerType) bool

CanReply returns true if the given Handler has to reply back to the user. It's the opposite of CanTrigger.

func CanTrigger

func CanTrigger(handlerType HandlerType) bool

CanTrigger returns true if the given Handler must not reply back to the user. Only publishers are trigger-able.

func ExternalUrl

func ExternalUrl(id string, port uint64) string

ExternalUrl creates url of the handler url for binding. For clients to connect to this url, call client.ClientUrl()

func InstanceHandleUrl

func InstanceHandleUrl(parentId string, id string) string

InstanceHandleUrl returns the url of the instance for handling the requests

func InstanceManagerEventUrl

func InstanceManagerEventUrl(handlerId string) string

InstanceManagerEventUrl returns a socket that's used to update the instance manager status

func InstanceUrl

func InstanceUrl(parentId string, id string) string

InstanceUrl returns the url of the instance for managing the instance itself

func IsValid

func IsValid(t HandlerType) error

IsValid checks whether the given string is the valid or not. If not valid, then returns the error otherwise returns nil.

func ManagerUrl

func ManagerUrl(handlerId string) string

ManagerUrl returns the handler manager socket

func ParentUrl

func ParentUrl(handlerId string) string

ParentUrl returns the url of the instance manager

func SocketType

func SocketType(handlerType HandlerType) zmq.Type

SocketType gets the ZMQ analog of the handler type

func UrlToFileName

func UrlToFileName(url string) string

UrlToFileName converts the given url to the file name. Simply it replaces the slashes with dots.

ExternalUrl returns the full url to connect to the orchestra.

The orchestra url is defined from the main service's url.

For example:

serviceUrl = "github.com/ahmetson/sample-service"
contextUrl = "orchestra.github.com.ahmetson.sample-service"

This url is set as the handler's name in the config. Then the handler package will generate an inproc:// url based on the handler name.

Types

type Handler

type Handler struct {
	Type           HandlerType `json:"type" yaml:"type"`
	Category       string      `json:"category" yaml:"category"`
	InstanceAmount uint64      `json:"instance_amount" yaml:"instance_amount"`
	Port           uint64      `json:"port" yaml:"port"`
	Id             string      `json:"id" yaml:"id"`
}

func ByCategory

func ByCategory(handlers []*Handler, category string) []*Handler

ByCategory returns handlers filtered by the category.

func NewHandler

func NewHandler(as HandlerType, cat string) (*Handler, error)

NewHandler configuration of the HandlerType and category. It generates the ID of the handler, as well as gets the free port.

If not possible to get the port, it returns an error.

func NewInternalHandler

func NewInternalHandler(as HandlerType, cat string) *Handler

NewInternalHandler returns the configuration with the default parameters

func (*Handler) IsInproc

func (handler *Handler) IsInproc() bool

IsInproc returns true if the handler is not a remote handler.

type HandlerType

type HandlerType string

HandlerType defines the available kind of handlers

const (
	// SyncReplierType handlers process a one request at a time.
	SyncReplierType HandlerType = "SyncReplier"
	// PublisherType handlers broadcast the message to all subscribers. It's a trigger-able handler.
	PublisherType HandlerType = "Publisher"
	// ReplierType handlers are the asynchronous ReplierType. It's a traditional client-server's server.
	ReplierType HandlerType = "Replier"
	PairType    HandlerType = "Pair"
	UnknownType HandlerType = ""
	WorkerType              = "Worker" // Workers are receiving the messages but don't return any result to the caller.
)

type Trigger

type Trigger struct {
	*Handler
	BroadcastPort uint64      `json:"broadcast_port" yaml:"broadcast_port"`
	BroadcastId   string      `json:"broadcast_id" yaml:"broadcast_id"`
	BroadcastType HandlerType `json:"broadcast_type" yaml:"broadcast_type"`
}

func InternalTriggerAble

func InternalTriggerAble(handler *Handler, as HandlerType) (*Trigger, error)

InternalTriggerAble Converts the Handler to Trigger of the given type for internal use

func TriggerAble

func TriggerAble(handler *Handler, as HandlerType) (*Trigger, error)

TriggerAble Converts the Handler to Trigger of the given type.

The trigger's type defines the broadcasting parameter. If trigger is remote, then broadcast is remote as well.

func (*Trigger) IsInprocBroadcast

func (trigger *Trigger) IsInprocBroadcast() bool

IsInprocBroadcast returns true if the publisher is not a remote.

Jump to

Keyboard shortcuts

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