message

package
v0.0.0-...-0cc5829 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MPL-2.0 Imports: 6 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JoinMessages

func JoinMessages(messages []string) string

JoinMessages into the single string the array of zeromq rawReq

func MultiPart

func MultiPart(messages []string) bool

MultiPart returns true if the message has id, delimiter, and content

func RawTraceIndex

func RawTraceIndex(messages []string) int

func SyncReplierEnvelope

func SyncReplierEnvelope(messages []string) bool

func ValidCommand

func ValidCommand(cmd string) error

ValidCommand checks if the reply type is failure, then THe message should be given too

func ValidFail

func ValidFail(status ReplyStatus, msg string) error

ValidFail checks if the reply type is failure, then THe message should be given too

func ValidStatus

func ValidStatus(status ReplyStatus) error

ValidStatus validates the status of the reply. It should be either OK or fail.

Types

type NewGenericReply

type NewGenericReply = func() ReplyInterface

type NewGenericReq

type NewGenericReq = func() RequestInterface

type Operations

type Operations struct {
	Name       string
	NewReq     ReqFunc
	NewReply   ReplyFunc
	EmptyReq   NewGenericReq
	EmptyReply NewGenericReply
}

func DefaultMessage

func DefaultMessage() *Operations

DefaultMessage returns a message for parsing request and parsing reply.

func RawMessage

func RawMessage() *Operations

RawMessage returns a message for parsing request and parsing reply.

type RawReply

type RawReply struct {
	Uuid string
	// contains filtered or unexported fields
}

func (*RawReply) Bytes

func (reply *RawReply) Bytes() ([]byte, error)

Bytes convert the message to the sequence of bytes

func (*RawReply) ConId

func (reply *RawReply) ConId() string

func (*RawReply) ErrorMessage

func (reply *RawReply) ErrorMessage() string

ErrorMessage if it was a Reply

func (*RawReply) IsOK

func (reply *RawReply) IsOK() bool

IsOK is unsupported

func (*RawReply) ReplyParameters

func (reply *RawReply) ReplyParameters() key_value.KeyValue

ReplyParameters returns the parameters if it was a Reply

func (*RawReply) SetConId

func (reply *RawReply) SetConId(conId string)

func (*RawReply) SetStack

func (reply *RawReply) SetStack(serviceUrl string, serverName string, serverInstance string) error

SetStack adds the current service's server into the reply

func (*RawReply) String

func (reply *RawReply) String() string

String the message

func (*RawReply) Traces

func (reply *RawReply) Traces() []*Stack

func (*RawReply) ZmqEnvelope

func (reply *RawReply) ZmqEnvelope() ([]string, error)

ZmqEnvelope the message

type RawRequest

type RawRequest struct {
	Uuid string
	// contains filtered or unexported fields
}

RawRequest is the wrapper around zeromq message envelope.

func (*RawRequest) AddRequestStack

func (request *RawRequest) AddRequestStack(serviceUrl string, serverName string, serverInstance string)

AddRequestStack adds the new trace into the request. This method shall be called by the handlers. Users should not work with this.

func (*RawRequest) Bytes

func (request *RawRequest) Bytes() ([]byte, error)

Bytes convert the message to the sequence of bytes

func (*RawRequest) CommandName

func (request *RawRequest) CommandName() string

CommandName returns the command name if it was a Request

func (*RawRequest) ConId

func (request *RawRequest) ConId() string

ConId returns a connection id for each sending session.

func (*RawRequest) Fail

func (request *RawRequest) Fail(message string) ReplyInterface

Fail creates a new Reply as a failure It accepts the error message that explains the reason of the failure.

func (*RawRequest) IsFirst

func (request *RawRequest) IsFirst() bool

IsFirst returns true if the request has no trace,

For example, if the proxy inserts it.

func (*RawRequest) Next

func (request *RawRequest) Next(command string, parameters key_value.KeyValue)

Next creates a new request based on the previous one. It uses the Request.

func (*RawRequest) Ok

func (request *RawRequest) Ok(parameters key_value.KeyValue) ReplyInterface

func (*RawRequest) PublicKey

func (request *RawRequest) PublicKey() string

PublicKey For security; Work in Progress.

func (*RawRequest) RouteParameters

func (request *RawRequest) RouteParameters() key_value.KeyValue

RouteParameters returns the parameters if it was a Request

func (*RawRequest) SetConId

func (request *RawRequest) SetConId(conId string)

func (*RawRequest) SetMeta

func (request *RawRequest) SetMeta(meta map[string]string)

func (*RawRequest) SetPublicKey

func (request *RawRequest) SetPublicKey(publicKey string)

SetPublicKey For security; Work in Progress.

func (*RawRequest) SetUuid

func (request *RawRequest) SetUuid()

func (*RawRequest) String

func (request *RawRequest) String() string

String the message

func (*RawRequest) SyncTrace

func (request *RawRequest) SyncTrace(reply ReplyInterface)

SyncTrace is if the reply has more stacks, the request is updated with it. The reply is generated by request.Next(). Once the request.Next() was used, the reply is returned. Update the request with the reply parameters

func (*RawRequest) Traces

func (request *RawRequest) Traces() []*Stack

func (*RawRequest) ZmqEnvelope

func (request *RawRequest) ZmqEnvelope() ([]string, error)

ZmqEnvelope the message

type Reply

type Reply struct {
	Uuid       string             `json:"uuid,omitempty"`
	Trace      []*Stack           `json:"traces,omitempty"`
	Status     ReplyStatus        `json:"status"`     // message.OK or message.FAIL
	Message    string             `json:"message"`    // If Status is fail, then the field will contain an error message.
	Parameters key_value.KeyValue `json:"parameters"` // If the Status is OK, then the field will contain the parameters.
	// contains filtered or unexported fields
}

Reply SDS Service returns the reply. Anyone who sends a request to the SDS Service gets this message.

func (*Reply) Bytes

func (reply *Reply) Bytes() ([]byte, error)

Bytes converts Reply to the sequence of bytes

func (*Reply) ConId

func (reply *Reply) ConId() string

func (*Reply) ErrorMessage

func (reply *Reply) ErrorMessage() string

func (*Reply) IsOK

func (reply *Reply) IsOK() bool

IsOK returns the Status of the message.

func (*Reply) ReplyParameters

func (reply *Reply) ReplyParameters() key_value.KeyValue

func (*Reply) SetConId

func (reply *Reply) SetConId(conId string)

func (*Reply) SetStack

func (reply *Reply) SetStack(serviceUrl string, serverName string, serverInstance string) error

SetStack adds the current service's server into the reply

func (*Reply) String

func (reply *Reply) String() string

String converts the Reply to the string format

func (*Reply) Traces

func (reply *Reply) Traces() []*Stack

func (*Reply) ZmqEnvelope

func (reply *Reply) ZmqEnvelope() ([]string, error)

type ReplyFunc

type ReplyFunc = func(zmqEnvelope []string) (ReplyInterface, error)

type ReplyInterface

type ReplyInterface interface {
	ConId() string
	SetConId(string)
	// SetStack adds the current service's server into the reply
	SetStack(serviceUrl string, serverName string, serverInstance string) error
	// IsOK returns the Status of the message.
	IsOK() bool
	// String converts the Reply to the string format. Empty if occurred an error.
	// It implements Stringer interface from a standard library
	String() string
	// ZmqEnvelope converts the message to the zeromq envelope
	ZmqEnvelope() ([]string, error)
	// Bytes converts Reply to the sequence of bytes
	Bytes() ([]byte, error)
	Traces() []*Stack
	ErrorMessage() string
	ReplyParameters() key_value.KeyValue
}

func NewEmptyRawReply

func NewEmptyRawReply() ReplyInterface

func NewEmptyReply

func NewEmptyReply() ReplyInterface

func NewRawRep

func NewRawRep(messages []string) (ReplyInterface, error)

func NewRep

func NewRep(messages []string) (ReplyInterface, error)

NewRep decodes Zeromq messages into Reply.

type ReplyStatus

type ReplyStatus string

ReplyStatus can be only as "OK" or "fail" It indicates whether the reply message is correct or not.

const (
	OK   ReplyStatus = "OK"
	FAIL ReplyStatus = "fail"
)

type ReqFunc

type ReqFunc = func(zmqEnvelope []string) (RequestInterface, error)

type Request

type Request struct {
	Uuid       string             `json:"uuid,omitempty"`
	Trace      []*Stack           `json:"traces,omitempty"`
	Command    string             `json:"command"`
	Parameters key_value.KeyValue `json:"parameters"`
	// contains filtered or unexported fields
}

Request message sent by Client socket and accepted by ControllerCategory socket.

func (*Request) AddRequestStack

func (request *Request) AddRequestStack(serviceUrl string, serverName string, serverInstance string)

func (*Request) Bytes

func (request *Request) Bytes() ([]byte, error)

Bytes convert the message to the sequence of bytes

func (*Request) CommandName

func (request *Request) CommandName() string

CommandName returns a command name

func (*Request) ConId

func (request *Request) ConId() string

ConId returns a connection id for each sending session.

func (*Request) Fail

func (request *Request) Fail(message string) ReplyInterface

Fail creates a new Reply as a failure It accepts the error message that explains the reason of the failure.

func (*Request) IsFirst

func (request *Request) IsFirst() bool

IsFirst returns true if the request has no trace,

For example, if the proxy inserts it.

func (*Request) Next

func (request *Request) Next(command string, parameters key_value.KeyValue)

Next creates a new request based on the previous one.

func (*Request) Ok

func (request *Request) Ok(parameters key_value.KeyValue) ReplyInterface

func (*Request) PublicKey

func (request *Request) PublicKey() string

PublicKey For security; Work in Progress.

func (*Request) RouteParameters

func (request *Request) RouteParameters() key_value.KeyValue

RouteParameters returns a command name

func (*Request) SetConId

func (request *Request) SetConId(conId string)

func (*Request) SetMeta

func (request *Request) SetMeta(meta map[string]string)

func (*Request) SetPublicKey

func (request *Request) SetPublicKey(publicKey string)

SetPublicKey For security; Work in Progress.

func (*Request) SetUuid

func (request *Request) SetUuid()

func (*Request) String

func (request *Request) String() string

JoinMessages the message

func (*Request) SyncTrace

func (request *Request) SyncTrace(reply ReplyInterface)

SyncTrace is if the reply has more stacks, the request is updated with it.

func (*Request) Traces

func (request *Request) Traces() []*Stack

func (*Request) ZmqEnvelope

func (request *Request) ZmqEnvelope() ([]string, error)

type RequestInterface

type RequestInterface interface {
	// ConId returns a connection id for each sending session.
	ConId() string
	SetConId(string)
	// IsFirst returns true if the request has no trace request or id,
	IsFirst() bool
	SyncTrace(ReplyInterface)
	AddRequestStack(serviceUrl string, serverName string, serverInstance string)
	// Bytes convert the message to the sequence of bytes
	Bytes() ([]byte, error)
	// PublicKey For security; Work in Progress.
	PublicKey() string
	// SetPublicKey For security; Work in Progress.
	SetPublicKey(publicKey string)
	// String implements the Stringer interface from a standard library
	String() string
	// ZmqEnvelope converts the message to the zeromq envelope
	ZmqEnvelope() ([]string, error)
	SetUuid()
	// Next creates a new request based on the previous one.
	Next(command string, parameters key_value.KeyValue)
	// Fail creates a new Reply as a failure
	// It accepts the error message that explains the reason of the failure.
	Fail(message string) ReplyInterface
	Ok(parameters key_value.KeyValue) ReplyInterface
	Traces() []*Stack
	SetMeta(map[string]string)
	CommandName() string
	RouteParameters() key_value.KeyValue
}

RequestInterface generic requests

func NewEmptyRawReq

func NewEmptyRawReq() RequestInterface

func NewEmptyReq

func NewEmptyReq() RequestInterface

func NewRawReq

func NewRawReq(messages []string) (RequestInterface, error)

NewRawReq from the zeromq rawReq.

func NewReq

func NewReq(messages []string) (RequestInterface, error)

NewReq from the zeromq messages

type Stack

type Stack struct {
	RequestTime    uint64 `json:"request_time"`
	ReplyTime      uint64 `json:"reply_time,omitempty"`
	Command        string `json:"command"`
	ServiceUrl     string `json:"service_url"`
	ServerName     string `json:"server_name"`
	ServerInstance string `json:"server_instance"`
}

Stack keeps the parameters of the message in the service.

Jump to

Keyboard shortcuts

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