Documentation
¶
Index ¶
- Constants
- func CanReply(handlerType HandlerType) bool
- func CanTrigger(handlerType HandlerType) bool
- func ExternalUrl(id string, port uint64) string
- func InstanceHandleUrl(parentId string, id string) string
- func InstanceManagerEventUrl(handlerId string) string
- func InstanceUrl(parentId string, id string) string
- func IsValid(t HandlerType) error
- func ManagerUrl(handlerId string) string
- func ParentUrl(handlerId string) string
- func SocketType(handlerType HandlerType) zmq.Type
- func UrlToFileName(url string) string
- type Handler
- type HandlerType
- type Trigger
Constants ¶
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 ¶
ExternalUrl creates url of the handler url for binding. For clients to connect to this url, call client.ClientUrl()
func InstanceHandleUrl ¶
InstanceHandleUrl returns the url of the instance for handling the requests
func InstanceManagerEventUrl ¶
InstanceManagerEventUrl returns a socket that's used to update the instance manager status
func InstanceUrl ¶
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 ¶
ManagerUrl returns the handler manager socket
func SocketType ¶
func SocketType(handlerType HandlerType) zmq.Type
SocketType gets the ZMQ analog of the handler type
func UrlToFileName ¶
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 ¶
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
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 ¶
IsInprocBroadcast returns true if the publisher is not a remote.