payload

package
v5.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultErrorMessage = "Unknown Error"

DefaultErrorMessage contains the default message to use for errors.

View Source
const DefaultErrorStatus = "500 Internal Server Error"

DefaultErrorStatus contains the default status to use for errors.

View Source
const HTTPResponseContentType = "text/plain"

HTTPResponseContentType defines the default HTTP content type to use for responses.

View Source
const HTTPResponseStatus = "200 OK"

HTTPResponseStatus defines the default HTTP status to use for responses.

View Source
const HTTPResponseVersion = "1.1"

HTTPResponseVersion defines the default HTTP version to use for responses.

View Source
const TransactionCommit = "commit"

TransactionCommit defines the command type for commit transactions.

View Source
const TransactionComplete = "complete"

TransactionComplete defines the command type for complete transactions.

View Source
const TransactionRollback = "rollback"

TransactionRollback defines the command type for rollback transactions.

View Source
const TypeArray = "array"

TypeArray defines the KUSANAGI type for array values.

View Source
const TypeBinary = "binary"

TypeBinary defines the KUSANAGI type for binary values.

View Source
const TypeBoolean = "boolean"

TypeBoolean defines the KUSANAGI type for boolean values.

View Source
const TypeFloat = "float"

TypeFloat defines the KUSANAGI type for float values.

View Source
const TypeInteger = "integer"

TypeInteger defines the KUSANAGI type for integer values.

View Source
const TypeNull = "null"

TypeNull defines the KUSANAGI type for null values.

View Source
const TypeObject = "object"

TypeObject defines the KUSANAGI type for object values.

View Source
const TypeString = "string"

TypeString defines the KUSANAGI type for string values.

Variables

This section is empty.

Functions

func IsValidType

func IsValidType(name string) bool

IsValidType check is a type name is supported by the framework.

Types

type ActionFiles

type ActionFiles []File

ActionFiles contains all the files sent to an action during a runtime call.

type ActionParams

type ActionParams []Param

ActionParams contains all the parameters sent to an action during a runtime call.

type ActionSchema

type ActionSchema struct {
	Timeout       uint                   `json:"x"`
	EntityPath    string                 `json:"e"`
	PathDelimiter string                 `json:"d"`
	Collection    *bool                  `json:"c,omitempty"`
	Calls         [][]string             `json:"C,omitempty"`
	DeferredCalls [][]string             `json:"dc,omitempty"`
	RemoteCalls   [][]string             `json:"rc,omitempty"`
	Fallback      *FallbackSchema        `json:"F,omitempty"`
	Deprecated    *bool                  `json:"D,omitempty"`
	HTTP          HTTPActionSchema       `json:"h,omitempty"`
	Params        map[string]ParamSchema `json:"p,omitempty"`
	Files         map[string]FileSchema  `json:"f,omitempty"`
	Entity        *EntitySchema          `json:"R,omitempty"`
	Relations     []RelationSchema       `json:"r,omitempty"`
	Return        *ReturnSchema          `json:"rv,omitempty"`
	Tags          []string               `json:"t,omitempty"`
}

ActionSchema contains the schema definition for an action.

type Call

type Call struct {
	Name     string  `json:"n"`
	Version  string  `json:"v"`
	Action   string  `json:"a"`
	Caller   string  `json:"C"`
	Duration uint    `json:"D"`
	Gateway  string  `json:"g,omitempty"`
	Timeout  uint    `json:"x,omitempty"`
	Params   []Param `json:"p,omitempty"`
	Files    []File  `json:"f,omitempty"`
}

Call represents a call to a service.

type CallInfo

type CallInfo struct {
	Service string  `json:"s"`
	Version string  `json:"v"`
	Action  string  `json:"a"`
	Params  []Param `json:"p,omitempty"`
}

CallInfo contains the information of the service to contact.

type Calls

type Calls map[string]map[string][]Call

Calls contains the transport calls.

type Command

type Command struct {
	Command CommandInfo `json:"c"`
	Meta    CommandMeta `json:"m"`
}

Command represents a framework command payload.

func NewCommand

func NewCommand(name, scope string) Command

NewCommand creates a new command payload.

func (Command) GetAttributes

func (c Command) GetAttributes() map[string]string

GetAttributes returns the command attributes.

func (Command) GetCall

func (c Command) GetCall() *CallInfo

GetCall returns the information of the service to contact.

func (Command) GetName

func (c Command) GetName() string

GetName returns the name of the command.

func (Command) GetRequestID

func (c Command) GetRequestID() string

GetRequestID returns the ID of the current request.

func (Command) GetResponse

func (c Command) GetResponse() *HTTPResponse

GetResponse returns the HTTP response payload.

func (Command) GetTransport

func (c Command) GetTransport() *Transport

GetTransport returns the transport payload.

type CommandArguments

type CommandArguments struct {
	// NOTE: "A" might contain the action name (string) or attributes (map[string]string)
	A interface{} `json:"a,omitempty"`

	// NOTE: "C" might contain the callee ([]string) or call info (map[string]interface{})
	C interface{} `json:"c,omitempty"`

	Meta      Meta          `json:"m,omitempty"`
	Request   *HTTPRequest  `json:"r,omitempty"`
	Response  *HTTPResponse `json:"R,omitempty"`
	Transport *Transport    `json:"T,omitempty"`
	Params    ActionParams  `json:"p,omitempty"` // TODO: The specs seem to be wrong here
	Files     ActionFiles   `json:"f,omitempty"`
	Return    interface{}   `json:"rv,omitempty"`
}

CommandArguments contains the arguments of the command. TODO: The specs need to fix the name clashes for "c" and "a" in the arguments.

func (*CommandArguments) GetAction

func (a *CommandArguments) GetAction() string

GetAction returns the action name for the call.

func (*CommandArguments) GetAttributes

func (a *CommandArguments) GetAttributes() map[string]string

GetAttributes returns the attributes for the command.

func (*CommandArguments) GetCall

func (a *CommandArguments) GetCall() *CallInfo

GetCall returns the info for the call.

func (*CommandArguments) GetCallee

func (a *CommandArguments) GetCallee() (callee []string)

GetCallee returns the callee service information.

func (*CommandArguments) SetAction

func (a *CommandArguments) SetAction(name string)

SetAction sets the name of the action for the call.

func (*CommandArguments) SetCallee

func (a *CommandArguments) SetCallee(callee []string)

SetCallee sets the calle service information.

type CommandInfo

type CommandInfo struct {
	Name      string            `json:"n"`
	Arguments *CommandArguments `json:"a,omitempty"`
}

CommandInfo contains the semantics of the command.

type CommandMeta

type CommandMeta struct {
	Scope string `json:"s"`
}

CommandMeta contains the meta-data associated with the command.

type CommandReply

type CommandReply struct {
	Name   string        `json:"n"`
	Result CommandResult `json:"r"`
}

CommandReply represents a successful reply to a command.

func (CommandReply) IsAction

func (r CommandReply) IsAction() bool

IsAction checks if the reply is a service action reply.

func (CommandReply) IsRequest

func (r CommandReply) IsRequest() bool

IsRequest checks if the reply is a middleware request reply.

func (CommandReply) IsResponse

func (r CommandReply) IsResponse() bool

IsResponse checks if the reply is a middleware response reply.

type CommandResult

type CommandResult struct {
	Attributes map[string]string `json:"a,omitempty"`
	Call       *CallInfo         `json:"c,omitempty"`
	Response   *HTTPResponse     `json:"R,omitempty"`
	Transport  *Transport        `json:"T,omitempty"`
	Return     interface{}       `json:"rv,omitempty"`
}

CommandResult contains the result values of a command reply.

type EntitySchema

type EntitySchema struct {
	Field      []FieldSchema       `json:"f,omitempty"`
	Fields     []ObjectFieldSchema `json:"F,omitempty"`
	Name       string              `json:"n,omitempty"`
	Validate   bool                `json:"V,omitempty"`
	Primarykey string              `json:"k,omitempty"`
}

EntitySchema contains the schema for an entity definition.

type Error

type Error struct {
	Message string `json:"m"`
	Code    int    `json:"c"`
	Status  string `json:"s"`
}

Error represents a reply that is returned when there is an error during command execution.

func (Error) GetCode

func (e Error) GetCode() int

GetCode returns the error code.

func (Error) GetMessage

func (e Error) GetMessage() string

GetMessage returns the error message.

func (Error) GetStatus

func (e Error) GetStatus() string

GetStatus returns the status message of the error.

type Errors

type Errors map[string]map[string]map[string][]Error

Errors contains the transport errors.

type Fallback

type Fallback []interface{}

Fallback contains the triggered fallbacks.

func (Fallback) GetActionNames

func (f Fallback) GetActionNames() (actions []string)

GetActionNames returns the list of action names where fallbacks were triggered.

func (Fallback) GetName

func (f Fallback) GetName() string

GetName returns the service name.

func (Fallback) GetVersion

func (f Fallback) GetVersion() string

GetVersion returns the service version.

type FallbackError

type FallbackError []interface{}

FallbackError contains a fallback error.

func (FallbackError) GetCode

func (e FallbackError) GetCode() (int, bool)

GetCode returns the error code.

func (FallbackError) GetMessage

func (e FallbackError) GetMessage() (string, bool)

GetMessage returns the error message.

func (FallbackError) GetStatus

func (e FallbackError) GetStatus() (string, bool)

GetStatus returns the status message of the errror.

type FallbackObject

type FallbackObject map[string]FallbackValue

FallbackObject contains the fallback data objects

type FallbackRelation

type FallbackRelation []interface{}

FallbackRelation contains the fallback relations.

func (FallbackRelation) GetForeignKey

func (r FallbackRelation) GetForeignKey() (string, bool)

GetForeignKey returns the foreign key value for a "one-to-one" relation.

func (FallbackRelation) GetForeignKeys

func (r FallbackRelation) GetForeignKeys() ([]string, bool)

GetForeignKeys returns the foreign key values for a "one-to-many" relation.

func (FallbackRelation) GetPrimaryKey

func (r FallbackRelation) GetPrimaryKey() (string, bool)

GetPrimaryKey returns the value for the primary key.

func (FallbackRelation) GetRemoteService

func (r FallbackRelation) GetRemoteService() (string, bool)

GetRemoteService returns the name of the remote service.

func (FallbackRelation) IsOneToMany

func (r FallbackRelation) IsOneToMany() bool

IsOneToMany checks if the relation is a "one-to-many" relation.

type FallbackSchema

type FallbackSchema struct {
	Properties map[string]string  `json:"p,omitempty"`
	Data       []FallbackObject   `json:"d,omitempty"`
	Relations  []FallbackRelation `json:"r,omitempty"`
	Links      map[string]string  `json:"l,omitempty"`
	Errors     []FallbackError    `json:"e,omitempty"`
}

FallbackSchema contains the schema definition for the transport fallback.

type FallbackValue

type FallbackValue struct {
	Type  string          `json:"t,omitempty"`
	Value interface{}     `json:"v,omitempty"`
	Items []FallbackValue `json:"i,omitempty"`
}

FallbackValue contains the value(s) and type of a fallback object.

"Value" contains the value when the type is not array, otherwise the values are stored in the "Items" property.

func (FallbackValue) GetItems

func (v FallbackValue) GetItems() ([]FallbackValue, bool)

GetItems returns the fallback values when the type is array.

func (FallbackValue) GetType

func (v FallbackValue) GetType() string

GetType returns the value type.

func (FallbackValue) GetValue

func (v FallbackValue) GetValue() (interface{}, bool)

GetValue returns the fallback value when the type is not array.

func (FallbackValue) IsArray

func (v FallbackValue) IsArray() bool

IsArray checks that the value type is an array.

type FieldSchema

type FieldSchema struct {
	Name     string `json:"n"`
	Type     string `json:"t"`
	Optional bool   `json:"o,omitempty"`
}

FieldSchema contains the schema for an entity field.

type File

type File struct {
	Name     string `json:"n"`
	Path     string `json:"p"`
	Mime     string `json:"m"`
	Filename string `json:"f"`
	Size     uint   `json:"s"`
	Token    string `json:"t,omitempty"`
}

File represents a file parameter.

func (File) GetMime

func (f File) GetMime() string

GetMime returns the mime type of the file.

type FileSchema

type FileSchema struct {
	Mime         string         `json:"m,omitempty"`
	Required     bool           `json:"r,omitempty"`
	Max          uint           `json:"mx,omitempty"`
	ExclusiveMax bool           `json:"ex,omitempty"`
	Min          uint           `json:"mn,omitempty"`
	ExclusiveMin bool           `json:"en,omitempty"`
	HTTP         HTTPFileSchema `json:"h,omitempty"`
}

FileSchema contains the schema definition of action file.

type Files

type Files map[string]map[string]map[string]map[string][]File

Files contains the transport files.

func (Files) Get

func (f Files) Get(address, name, version, action string) []File

Get returns the files for the given service action.

address: The gateway address. name: The service name. version: The service version. action: The action name.

type HTTPActionSchema

type HTTPActionSchema struct {
	Gateway *bool    `json:"g,omitempty"`
	Path    string   `json:"p,omitempty"`
	Method  string   `json:"m,omitempty"`
	Input   string   `json:"i,omitempty"`
	Body    []string `json:"b,omitempty"`
}

HTTPActionSchema contains the HTTP schema definition for the action.

type HTTPFileSchema

type HTTPFileSchema struct {
	Gateway *bool  `json:"g,omitempty"`
	Param   string `json:"p,omitempty"`
}

HTTPFileSchema contains the HTTP schema definition for a file.

type HTTPParamSchema

type HTTPParamSchema struct {
	Gateway *bool  `json:"g,omitempty"`
	Input   string `json:"i,omitempty"`
	Param   string `json:"p,omitempty"`
}

HTTPParamSchema contains the HTTP schema definition for a parameter.

type HTTPRequest

type HTTPRequest struct {
	Version  string          `json:"v"`
	Method   string          `json:"m"`
	URL      string          `json:"u"`
	Query    HTTPRequestData `json:"q"`
	PostData HTTPRequestData `json:"p"`
	Headers  http.Header     `json:"h"`
	Body     []byte          `json:"b"`
	Files    []File          `json:"f"`
}

HTTPRequest represents the semantics of an HTTP request.

type HTTPRequestData

type HTTPRequestData map[string][]string

HTTPRequestData contains data sent in a request.

type HTTPResponse

type HTTPResponse struct {
	Version string      `json:"v"`
	Status  string      `json:"s"`
	Headers http.Header `json:"h"`
	Body    []byte      `json:"b"`
}

HTTPResponse represents the semantics of an HTTP response.

func NewHTTPResponse

func NewHTTPResponse() *HTTPResponse

NewHTTPResponse creates a new HTTP response payload.

func (HTTPResponse) GetHeaders

func (r HTTPResponse) GetHeaders() http.Header

GetHeaders returns the HTTP headers of the response.

func (HTTPResponse) GetStatus

func (r HTTPResponse) GetStatus() string

GetStatus returns the HTTP status code and text of the response.

func (HTTPResponse) GetVersion

func (r HTTPResponse) GetVersion() string

GetVersion returns the HTTP version of the response.

type HTTPSchema

type HTTPSchema struct {
	Gateway  *bool  `json:"g,omitempty"`
	BasePath string `json:"b"`
}

HTTPSchema contains the HTTP schema definitions for a service.

func (HTTPSchema) GetBasePath

func (h HTTPSchema) GetBasePath() string

GetBasePath returns the base path for the service.

func (HTTPSchema) GetGateway

func (h HTTPSchema) GetGateway() bool

GetGateway returns the service availability thought the gateway.

type Links map[string]map[string]map[string]string

Links contains the transport links.

type Mapping

type Mapping map[string]map[string]Schema

Mapping contains the schemas for the different services.

func (Mapping) GetSchema

func (m Mapping) GetSchema(name, version string) (*Schema, error)

GetSchema returns a schema for a service. The version can be either a fixed version or a pattern that uses "*" and resolves to the higher version available that matches.

name: The name of the service. version: The version of the service.

func (Mapping) GetServices

func (m Mapping) GetServices() (services []ServiceVersion)

GetServices returns the name and version of all the services in the mapping.

func (Mapping) GetVersions

func (m Mapping) GetVersions(name string) (versions []string)

GetVersions returns the versions for a services that are available in the mappings.

name: The name of the service.

type Meta

type Meta struct {
	Version    string            `json:"v"`
	ID         string            `json:"i"`
	Datetime   string            `json:"d"`
	Type       uint              `json:"t"`
	Protocol   string            `json:"p"`
	Gateway    []string          `json:"g"`
	Client     string            `json:"c"`
	Attributes map[string]string `json:"a,omitempty"`
}

Meta contains the meta-data associated with the payload.

func (Meta) GetGateway

func (m Meta) GetGateway() []string

GetGateway returns the gateway addresses.

The result contains two items, where the first item is the internal address and the second is the public address.

type ObjectFieldSchema

type ObjectFieldSchema struct {
	Name     string              `json:"n"`
	Field    []FieldSchema       `json:"f,omitempty"`
	Fields   []ObjectFieldSchema `json:"F,omitempty"`
	Optional bool                `json:"o,omitempty"`
}

ObjectFieldSchema contains the schema for an entity object field.

type Param

type Param struct {
	Name  string      `json:"n"`
	Value interface{} `json:"v,omitempty"`
	Type  string      `json:"t,omitempty"`
}

Param represents an action param.

type ParamSchema

type ParamSchema struct {
	Name         string          `json:"n"`
	Type         string          `json:"t,omitempty"`
	Format       string          `json:"f,omitempty"`
	ArrayFormat  string          `json:"af,omitempty"`
	Pattern      string          `json:"p,omitempty"`
	AllowEmpty   bool            `json:"e,omitempty"`
	DefaultValue interface{}     `json:"d,omitempty"`
	Required     bool            `json:"r,omitempty"`
	Items        string          `json:"i,omitempty"`
	Max          *float64        `json:"mx,omitempty"`
	ExclusiveMax bool            `json:"ex,omitempty"`
	Min          *float64        `json:"mn,omitempty"`
	ExclusiveMin bool            `json:"en,omitempty"`
	MaxItems     int             `json:"xi,omitempty"`
	MinItems     *int            `json:"ni,omitempty"`
	UniqueItems  bool            `json:"ui,omitempty"`
	Enum         []interface{}   `json:"em,omitempty"`
	MultipleOf   int             `json:"mo,omitempty"`
	HTTP         HTTPParamSchema `json:"h,omitempty"`
}

ParamSchema contains the schema definition of action parameters.

type RelationSchema

type RelationSchema struct {
	Name string `json:"n"`
	Type string `json:"t,omitempty"`
}

RelationSchema contains the schema for a relation.

type Relations

type Relations map[string]map[string]map[string]map[string]map[string]interface{}

Relations contains the transport relations.

type Reply

type Reply struct {
	Error   *Error        `json:"E,omitempty"`
	Command *CommandReply `json:"cr,omitempty"`
}

Reply represents a generic reply to a framework command.

func NewActionReply

func NewActionReply(c *Command) *Reply

NewActionReply creates a new command reply for a service call.

func NewErrorReply

func NewErrorReply() Reply

NewErrorReply creates a new error reply payload.

func NewRequestReply

func NewRequestReply(c *Command) *Reply

NewRequestReply creates a new command reply for a request.

func NewResponseReply

func NewResponseReply(c *Command) *Reply

NewResponseReply creates a new command reply for a response.

func (*Reply) ForRequest

func (r *Reply) ForRequest() Reply

ForRequest prepares the reply for a request middleware.

func (*Reply) ForResponse

func (r *Reply) ForResponse() Reply

ForResponse prepares the reply for a response middleware.

func (*Reply) GetReturnValue

func (r *Reply) GetReturnValue() interface{}

GetReturnValue returns the return value for the reply.

func (*Reply) GetTransport

func (r *Reply) GetTransport() *Transport

GetTransport returns the transport for the reply.

func (*Reply) IsCommand

func (r *Reply) IsCommand() bool

IsCommand checks if the reply is a command reply.

func (*Reply) IsError

func (r *Reply) IsError() bool

IsError checks if the reply is an error reply.

func (*Reply) IsValid

func (r *Reply) IsValid() bool

IsValid checks if the reply is a valid command reply.

func (*Reply) SetResponse

func (r *Reply) SetResponse(code int, text string) Reply

SetResponse sets a response in the payload.

code: The HTTP status code for the response. text: The HTTP status text for the response.

type ReturnSchema

type ReturnSchema struct {
	Type       string `json:"t"`
	AllowEmpty bool   `json:"e,omitempty"`
}

ReturnSchema contains the schema for the return value.

type Schema

type Schema struct {
	Address []string                `json:"a"`
	Files   *bool                   `json:"f,omitempty"`
	HTTP    HTTPSchema              `json:"h"`
	Actions map[string]ActionSchema `json:"ac"`
}

Schema contains the schema definitions for a service.

func (Schema) GetAddress

func (s Schema) GetAddress() []string

GetAddress returns the internal address of the hosts.

func (Schema) GetFiles

func (s Schema) GetFiles() bool

GetFiles returns the file server availability.

type ServiceData

type ServiceData map[string]map[string]map[string]map[string][]interface{}

ServiceData contains the transport data of the called services.

type ServiceVersion

type ServiceVersion struct {
	Name    string
	Version string
}

ServiceVersion contains the name and version of a service.

type Transaction

type Transaction struct {
	Name    string  `json:"n"`
	Version string  `json:"v"`
	Action  string  `json:"a"`
	Caller  string  `json:"C"`
	Params  []Param `json:"p,omitempty"`
}

Transaction represents a transaction object.

type Transactions

type Transactions map[string][]Transaction

Transactions contains the transport transactions.

func (Transactions) Get

func (t Transactions) Get(command string) (trx []Transaction)

Get the transactions for a comman type.

type Transport

type Transport struct {
	Meta         TransportMeta `json:"m"`
	Body         *File         `json:"b,omitempty"`
	Files        Files         `json:"f,omitempty"`
	Data         ServiceData   `json:"d,omitempty"`
	Relations    Relations     `json:"r,omitempty"`
	Links        Links         `json:"l,omitempty"`
	Transactions Transactions  `json:"t,omitempty"`
	Calls        Calls         `json:"C,omitempty"`
	Errors       Errors        `json:"e,omitempty"`
	// contains filtered or unexported fields
}

Transport contains the transport payload data.

func (*Transport) Clone

func (t *Transport) Clone() *Transport

Clone creates a clone of the transport.

The returned transport won't keep references to the original transport values.

func (*Transport) GetGateway

func (t *Transport) GetGateway() []string

GetGateway returns the gateway addresses.

The result contains two items, where the first item is the internal address and the second is the public address.

func (*Transport) GetLevel

func (t *Transport) GetLevel() uint

GetLevel returns the depth of service requests.

func (*Transport) GetOrigin

func (t *Transport) GetOrigin() []string

GetOrigin returns the origin service.

The result contains three items, where the first item is service name, the second is the version and the third is the action name.

func (*Transport) HasCalls

func (t *Transport) HasCalls(service, version string) bool

HasCalls checks if there are any type of calls registered for a Service.

service: The name of the Service. version: The version of the Service.

func (*Transport) SetCall

func (t *Transport) SetCall(
	service string,
	version string,
	action string,
	calleeService string,
	calleeVersion string,
	calleeAction string,
	duration uint,
	params []Param,
	files []File,
	timeout uint,
	transport *Transport,
) error

SetCall adds a run-time call.

Current transport payload is used when the optional transport is not given.

service: The name of the Service. version: The version of the Service. action: The name of the action making the call. callee_service: The called service. callee_version: The called version. callee_action: The called action. duration: The call duration. params: Optional parameters to send. files: Optional files to send. timeout: Optional timeout for the call. transport: Optional transport payload.

func (*Transport) SetData

func (t *Transport) SetData(name, version, action string, data interface{})

SetData add data from a call to the transport payload.

When there is existing data in the payload it is not removed. The new data is appended to the existing data in that case.

name: The name of the Service. version: The version of the Service. action: The name of the action. data: The data to add.

func (*Transport) SetDeferCall

func (t *Transport) SetDeferCall(
	service string,
	version string,
	action string,
	calleeService string,
	calleeVersion string,
	calleeAction string,
	params []Param,
	files []File,
)

SetDeferCall adds a deferred call.

service: The name of the Service. version: The version of the Service. action: The name of the action making the call. callee_service: The called service. callee_version: The called version. callee_action: The called action. params: Optional parameters to send. files: Optional files to send.

func (*Transport) SetDownload

func (t *Transport) SetDownload(f *File) bool

SetDownload assigns a file to the body.

file: The file to use as download content.

func (*Transport) SetError

func (t *Transport) SetError(service, version, message string, code int, status string)

SetError adds a service error.

service: The name of the Service. version: The version of the Service. message: The error message. code: The error code. status: The status message for the protocol.

func (t *Transport) SetLink(service, link, uri string)

SetLink adds a link.

service: The name of the Service. link: The link name. uri: The URI for the link.

func (*Transport) SetRelateMany

func (t *Transport) SetRelateMany(service, pk, remote string, fks []string)

SetRelateMany adds a "many-to-many" relation.

service: The name of the local service. pk: The primary key of the local entity. remote: The name of the remote service. fks: The primary keys of the remote entity.

func (*Transport) SetRelateManyRemote

func (t *Transport) SetRelateManyRemote(service, pk, address, remote string, fks []string)

SetRelateManyRemote adds a remote "many-to-many" relation.

service: The name of the local service. pk: The primary key of the local entity. address: The address of the remote gateway. remote: The name of the remote service. fks: The primary keys of the remote entity.

func (*Transport) SetRelateOne

func (t *Transport) SetRelateOne(service, pk, remote, fk string)

SetRelateOne adds a "one-to-one" relation.

service: The name of the local service. pk: The primary key of the local entity. remote: The name of the remote service. fk: The primary key of the remote entity.

func (*Transport) SetRelateOneRemote

func (t *Transport) SetRelateOneRemote(service, pk, address, remote, fk string)

SetRelateOneRemote adds a remote "one-to-one" relation.

service: The name of the local service. pk: The primary key of the local entity. address: The address of the remote gateway. remote: The name of the remote service. fk: The primary key of the remote entity.

func (*Transport) SetRemoteCall

func (t *Transport) SetRemoteCall(
	address string,
	service string,
	version string,
	action string,
	calleeService string,
	calleeVersion string,
	calleeAction string,
	timeout uint,
	params []Param,
	files []File,
)

SetRemoteCall adds a run-time call.

Current transport payload is used when the optional transport is not given.

address: The address of the remote Gateway. service: The name of the Service. version: The version of the Service. action: The name of the action making the call. callee_service: The called service. callee_version: The called version. callee_action: The called action. timeout: Optional timeout for the call. params: Optional parameters to send. files: Optional files to send.

func (*Transport) SetReply

func (t *Transport) SetReply(r *Reply) *Transport

SetReply assigns the the reply payload.

reply: The reply payload.

func (*Transport) SetReturn

func (t *Transport) SetReturn(value interface{}) bool

SetReturn assigns the return value of an action.

value: The value to use as return value in the payload.

func (*Transport) SetTransaction

func (t *Transport) SetTransaction(command, service, version, action, target string, params []Param)

SetTransaction adds a transaction to be called when the request succeeds.

command: The type of transaction. service: The name of the Service. version: The version of the Service. action: The name of the origin action. target: The name of the target action. params: Optional parameters for the transaction.

type TransportMeta

type TransportMeta struct {
	ID         string            `json:"i"`
	Version    string            `json:"v"`
	Datetime   string            `json:"d"`
	StartTime  string            `json:"s"`
	EndTime    string            `json:"e"`
	Duration   uint              `json:"D,omitempty"`
	Gateway    []string          `json:"g"`
	Origin     []string          `json:"o"`
	Level      uint              `json:"l"`
	Properties map[string]string `json:"p,omitempty"`
	Fallbacks  []Fallback        `json:"F,omitempty"`
}

TransportMeta contains the metadata of the transport.

Jump to

Keyboard shortcuts

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