kusanagi

package module
v2.0.0-...-1f73bd4 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ArrayFormatCSV = "csv"

List of array parameter formats

Possible array formats are, "csv" for comma separated values, "ssv" for space separated values, "tsv" for tab separated values, "pipes" for pipe separated values, or "multi" for multiple parameter arguments instead of a single string argument containing all the values.

View Source
const ArrayFormatMulti = "multi"
View Source
const ArrayFormatPipe = "pipe"
View Source
const ArrayFormatSSV = "ssv"
View Source
const ArrayFormatTSV = "tsv"

Transaction commands

View Source
const ExecutionTimeout = 30000

ExecutionTimeout defines the number of milliseconds to wait by default when an action is executed.

View Source
const RelationTypeMany = "many"
View Source
const RelationTypeOne = "one"

Types of relations between two services.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	*Api
	// contains filtered or unexported fields
}

Action API type for the service component.

func (*Action) Call

func (a *Action) Call(
	service string,
	version string,
	action string,
	params []Param,
	files []File,
	timeout uint,
) (interface{}, error)

Call performs a run-time call to a service.

The result of this call is the return value from the remote action.

service: The service name. version: The service version. action: The action name. params: Optional list of Param objects. files: Optional list of File objects. timeout: Optional timeout in milliseconds.

func (*Action) Commit

func (a *Action) Commit(action string, params []Param) (*Action, error)

Commit registers a transaction to be called when request succeeds.

action: The action name. params: Optional list of parameters.

func (*Action) Complete

func (a *Action) Complete(action string, params []Param) (*Action, error)

Complete registers a transaction to be called when request finishes.

action: The action name. params: Optional list of parameters.

func (*Action) DeferCall

func (a *Action) DeferCall(service, version, action string, params []Param, files []File) (*Action, error)

DeferCall registera a deferred call to a service.

service: The service name. version: The service version. action: The action name. params: Optional list of parameters. files: Optional list of files.

func (*Action) Error

func (a *Action) Error(message string, code int, status string) *Action

Error adds an error for the current service.

Adds an error object to the Transport with the specified message.

message: The error message. code: The error code. status: The HTTP status message.

func (*Action) GetActionName

func (a *Action) GetActionName() string

GetActionName returns the name of the action.

func (*Action) GetFile

func (a *Action) GetFile(name string) File

GetFile returns an uploaded file.

name: The name of the file parameter.

func (*Action) GetFiles

func (a *Action) GetFiles() (files []File)

GetFiles returns all the uploaded files.

func (*Action) GetParam

func (a *Action) GetParam(name string) Param

GetParam returns an action parameter.

name: The name of the parameter.

func (*Action) GetParams

func (a *Action) GetParams() (params []Param)

GetParams returns all the action's parameters.

func (*Action) HasFile

func (a *Action) HasFile(name string) bool

HasFile checks if a file was provided for the action.

name: The name of the file parameter.

func (*Action) HasParam

func (a *Action) HasParam(name string) bool

HasParam checks if a parameter exists.

name: The name of the parameter.

func (*Action) IsOrigin

func (a *Action) IsOrigin() bool

IsOrigin checks if the current service is the origin of the request.

func (*Action) NewFile

func (a *Action) NewFile(name, path, mimeType string) (*File, error)

NewFile creates a new file.

name: Name of the file parameter. path: Optional path to the file. mimeType: Optional MIME type of the file contents.

func (*Action) NewParam

func (a *Action) NewParam(name string, value interface{}, type_ string) (*Param, error)

NewParam creates a new parameter.

Creates an instance of Param with the given name, and optionally the value and data type. When the value is not provided then an empty string is assumed. If the data type is not defined then "string" is assumed.

name: The parameter name. value: The parameter value. type_: The data type of the value.

func (*Action) RelateMany

func (a *Action) RelateMany(pk, service string, fks []string) (*Action, error)

RelateMany creates a "one-to-many" relation between entities.

Creates a "one-to-many" relation between the entity's primary key and service with the foreign keys.

pk: The primary key. service: The foreign service. fks: The foreign keys.

func (*Action) RelateManyRemote

func (a *Action) RelateManyRemote(pk, address, service string, fks []string) (*Action, error)

RelateManyRemote creates a "one-to-many" relation between entities.

Creates a "one-to-many" relation between the entity's primary key and service with the foreign keys.

This type of relation is done between entities in different realms.

pk: The primary key. address: Foreign service public address. service: The foreign service. fks: The foreign keys.

func (*Action) RelateOne

func (a *Action) RelateOne(pk, service, fk string) (*Action, error)

RelateOne creates a "one-to-one" relation between entities.

Creates a "one-to-one" relation between the entity's primary key and service with the foreign key.

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

func (*Action) RelateOneRemote

func (a *Action) RelateOneRemote(pk, address, service, fk string) (*Action, error)

RelateOneRemote creates a "one-to-one" relation between two entities.

Creates a "one-to-one" relation between the entity's primary key and service with the foreign key.

This type of relation is done between entities in different realms.

pk: The primary key. address: Foreign service public address. service: The foreign service. fk: The foreign key.

func (*Action) RemoteCall

func (a *Action) RemoteCall(
	address string,
	service string,
	version string,
	action string,
	params []Param,
	files []File,
	timeout uint,
) (*Action, error)

RemoteCall registers a call to a remote service in another realm.

These types of calls are done using KTP (KUSANAGI transport protocol).

address: Public address of a gateway from another realm. service: The service name. version: The service version. action: The action name. params: Optional list of parameters. files: Optional list of files. timeout: Optional call timeout in milliseconds.

func (*Action) Rollback

func (a *Action) Rollback(action string, params []Param) (*Action, error)

Rollback registers a transaction to be called when request fails.

action: The action name. params: Optional list of parameters.

func (*Action) SetCollection

func (a *Action) SetCollection(collection []map[string]interface{}) *Action

SetCollection sets the collection data.

Collection is validated when validation is enabled for an entity in the service config file.

collection: The collection.

func (*Action) SetDownload

func (a *Action) SetDownload(f File) (*Action, error)

SetDownload sets a file as the download.

file: The file.

func (*Action) SetEntity

func (a *Action) SetEntity(entity map[string]interface{}) *Action

SetEntity set the entity data.

Sets an object as the entity to be returned by the action.

Entity is validated when validation is enabled for an entity in the service config file.

entity: The entity.

func (a *Action) SetLink(link, uri string) (*Action, error)

SetLink sets a link for the given URI.

link: The link name. uri: The link URI.

func (*Action) SetProperty

func (a *Action) SetProperty(name, value string) *Action

SetProperty sets a userland property in the transport.

name: The property name. value: The property value.

func (*Action) SetReturn

func (a *Action) SetReturn(value interface{}) (*Action, error)

SetReturns sets the value to be returned by the action.

value: The action's return value.

type ActionCallback

type ActionCallback func(*Action) (*Action, error)

ActionCallback is called when a service request is received.

type ActionData

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

ActionData represents the action data stored in the transport by a service.

func (ActionData) GetData

func (a ActionData) GetData() []interface{}

GetData returns the transport data for the service action.

Each item in the list represents a call that included data in the transport, where each item may be a slice or a map, depending on whether the data is a collection or not.

func (ActionData) GetName

func (a ActionData) GetName() string

GetName returns the name of the service action that returned the data.

func (ActionData) IsCollection

func (a ActionData) IsCollection() bool

IsCollection checks if the data for this action is a collection.

type ActionSchema

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

ActionSchema contains the schema definition for an action.

func (ActionSchema) GetCalls

func (s ActionSchema) GetCalls() (calls [][]string)

GetCalls returns the run-time service calls.

Each call item is a list containing the service name, the service version and the action name.

func (ActionSchema) GetDeferCalls

func (s ActionSchema) GetDeferCalls() (calls [][]string)

GetDeferCalls returns the deferred service calls.

Each call item is a list containing the service name, the service version and the action name.

func (ActionSchema) GetEntity

func (s ActionSchema) GetEntity() *Entity

GetEntity returns the entity definition.

func (ActionSchema) GetEntityPath

func (s ActionSchema) GetEntityPath() string

GetEntityPath returns the path to the entity.

func (ActionSchema) GetFileSchema

func (s ActionSchema) GetFileSchema(name string) (*FileSchema, error)

GetFileSchema returns the schema for a file parameter.

name: The file parameter name.

func (ActionSchema) GetFiles

func (s ActionSchema) GetFiles() (files []string)

GetFiles returns the file parameter names defined for the action.

func (ActionSchema) GetHTTPSchema

func (s ActionSchema) GetHTTPSchema() *HTTPActionSchema

GetHTTPSchema returns the HTTP schema.

func (ActionSchema) GetName

func (s ActionSchema) GetName() string

GetName returns the action name.

func (ActionSchema) GetParamSchema

func (s ActionSchema) GetParamSchema(name string) (*ParamSchema, error)

GetParamSchema returns the schema for a parameter.

name: The parameter name.

func (ActionSchema) GetParams

func (s ActionSchema) GetParams() (params []string)

GetParams returns the parameter names defined for the action.

func (ActionSchema) GetPathDelimiter

func (s ActionSchema) GetPathDelimiter() string

GetPathDelimiter returns the delimiter to use for the entity path.

func (ActionSchema) GetRelations

func (s ActionSchema) GetRelations() (relations [][]string)

GetRelations return the relations.

Each item is an array contains the relation type and the service name.

func (ActionSchema) GetRemoteCalls

func (s ActionSchema) GetRemoteCalls() (calls [][]string)

GetRemoteCalls returns the remote service calls.

Each call item is a list containing the public address of the gateway, the service name, the service version and the action name.

func (ActionSchema) GetReturnType

func (s ActionSchema) GetReturnType() (string, error)

GetReturnType returns the data type of the returned action value.

func (ActionSchema) GetTags

func (s ActionSchema) GetTags() (tags []string)

GetTags returns the tags defined for the action.

func (ActionSchema) GetTimeout

func (s ActionSchema) GetTimeout() uint

GetTimeout returns the maximum execution time defined in milliseconds for the action.

func (ActionSchema) HasCall

func (s ActionSchema) HasCall(name, version, action string) bool

HasCall checks if a run-time call exists for a service.

name: The service name. version: Optional service version. action: Optional action name.

func (ActionSchema) HasCalls

func (s ActionSchema) HasCalls() bool

HasCalls checks if any run-time call exists for the action.

func (ActionSchema) HasDeferCall

func (s ActionSchema) HasDeferCall(name, version, action string) bool

HasDeferCall checks if a deferred call exists for a service.

name: The service name. version: Optional service version. action: Optional action name.

func (ActionSchema) HasDeferCalls

func (s ActionSchema) HasDeferCalls() bool

HasDeferCalls checks if any deferred call exists for the action.

func (ActionSchema) HasEntity

func (s ActionSchema) HasEntity() bool

HasEntity checks if an entity definition exists for the action.

func (ActionSchema) HasFile

func (s ActionSchema) HasFile(name string) bool

HasFile checks that a schema for a file parameter exists.

name: The file parameter name.

func (ActionSchema) HasParam

func (s ActionSchema) HasParam(name string) bool

HasParam checks that a schema for a parameter exists.

name: The parameter name.

func (ActionSchema) HasRelations

func (s ActionSchema) HasRelations() bool

HasRelations checks if any relations exists for the action.

func (ActionSchema) HasRemoteCall

func (s ActionSchema) HasRemoteCall(address, name, version, action string) bool

HasRemoteCall checks if a remote call exists for a service.

address: Gateway address. name: Optional service name. version: Optional service version. action: Optional action name.

func (ActionSchema) HasRemoteCalls

func (s ActionSchema) HasRemoteCalls() bool

HasRemoteCalls checks if any remote call exists for the action.

func (ActionSchema) HasReturn

func (s ActionSchema) HasReturn() bool

HasReturn checks if a return value is defined for the action.

func (ActionSchema) HasTag

func (s ActionSchema) HasTag(name string) bool

HasTag checks if a tag is defined for the action.

The tag name is case sensitive.

name: The tag name.

func (ActionSchema) IsCollection

func (s ActionSchema) IsCollection() bool

IsCollection checks if the action returns a collection of entities.

func (ActionSchema) IsDeprecated

func (s ActionSchema) IsDeprecated() bool

IsDeprecated checks if the action has been deprecated.

func (ActionSchema) ResolveEntity

func (s ActionSchema) ResolveEntity(data map[string]interface{}) (map[string]interface{}, error)

ResolveEntity returns the entity extracted from the data.

Get the entity part, based upon the `entity-path` and `path-delimiter` properties in the action configuration.

data: The object to get entity from.

type Api

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

Api type for SDK components.

func (*Api) Done

func (a *Api) Done() bool

Done is a dummy method to comply with KUSANAGI SDK specifications.

func (*Api) GetAsyncContext

func (a *Api) GetAsyncContext() context.Context

GetAsyncContext return the context for the current request.

func (*Api) GetFrameworkVersion

func (a *Api) GetFrameworkVersion() string

GetFrameworkVersion gets the KUSANAGI framework version.

func (*Api) GetName

func (a *Api) GetName() string

Get component name.

func (*Api) GetPath

func (a *Api) GetPath() string

Get source file path.

func (*Api) GetResource

func (a *Api) GetResource(name string) (interface{}, error)

Get a resource.

name: The name of the resource.

func (*Api) GetServiceSchema

func (a *Api) GetServiceSchema(name, version string) (*ServiceSchema, error)

GetServiceSchema 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 (*Api) GetServices

func (a *Api) GetServices() []payload.ServiceVersion

Get service names and versions from the mapping schemas.

func (*Api) GetVariable

func (a *Api) GetVariable(name string) string

Get a single component variable.

name: The name of the variable.

func (*Api) GetVariables

func (a *Api) GetVariables() map[string]string

Gets all component variables.

func (*Api) GetVersion

func (a *Api) GetVersion() string

Get component version.

func (*Api) HasResource

func (a *Api) HasResource(name string) bool

Checks if a resource exists.

name: The name of the resource.

func (*Api) HasVariable

func (a *Api) HasVariable(name string) bool

Checks if a variable exists.

name: The name of the variable.

func (*Api) IsDebug

func (a *Api) IsDebug() bool

IsDebug checks if the component is running in debug mode.

func (*Api) Log

func (a *Api) Log(value interface{}, level int) (*Api, error)

Log writes a value to the KUSANAGI logs.

Given value is converted to string before being logged.

Output is truncated to have a maximum of 100000 characters.

value: The value to log. level: An optional log level to use for the log message.

type Callback

type Callback func(Component) error

Callback is called by components during startup and shutdown.

type Callee

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

Callee represents a service being called by another service.

func (Callee) GetAction

func (c Callee) GetAction() string

GetAction returns the name of the service action being called.

func (Callee) GetAddress

func (c Callee) GetAddress() string

GetAddress returns the public gateway address for calls to another realm.

func (Callee) GetDuration

func (c Callee) GetDuration() uint

GetDuration returns the duration of the call in milliseconds.

func (Callee) GetName

func (c Callee) GetName() string

GetName returns the name of the service being called.

func (Callee) GetParams

func (c Callee) GetParams() (params []Param)

GetParams returns the call parameters.

func (Callee) GetTimeout

func (c Callee) GetTimeout() uint

GetTimeout returns the timeout in milliseconds for a call to a service in another realm.

func (Callee) GetVersion

func (c Callee) GetVersion() string

GetVersion returns the version of the service being called.

func (Callee) IsRemote

func (c Callee) IsRemote() bool

IsRemote checks if the call is to a service in another Realm.

type Caller

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

Caller represents a service which registered call in the transport.

func (Caller) GetAction

func (c Caller) GetAction() string

GetAction returns the name of the service action that is making the call.

func (Caller) GetCallee

func (c Caller) GetCallee() Callee

GetCallee returns the callee info for the service being called.

func (Caller) GetName

func (c Caller) GetName() string

GetName returns the service name.

func (Caller) GetVersion

func (c Caller) GetVersion() string

GetVersion returns the service version.

type Component

type Component interface {
	// HasResource checks if a resource name exist.
	//
	// name: Name of the resource.
	HasResource(name string) bool

	// SetResource stores a resource.
	//
	// name: Name of the resource.
	// factory: A callable that returns the resource value.
	SetResource(name string, factory ResourceFactory) error

	// GetResource returns a resource.
	//
	// name: Name of the resource.
	GetResource(name string) (interface{}, error)

	// Startup registers a callback to be called during component startup.
	//
	// callback: A callback to execute on startup.
	Startup(callback Callback) Component

	// Shutdown registers allback to be called during component shutdown.
	//
	// callback: A callback to execute on shutdown.
	Shutdown(callback Callback) Component

	// Error registers a callback to be called error.
	//
	// callback: A callback to execute when the component fails to handle a request.
	Error(callback ErrorCallback) Component

	// Log writes a value to KUSANAGI logs.
	//
	// Given value is converted to string before being logged.
	//
	// Output is truncated to have a maximum of 100000 characters.
	//
	// value: The value to log.
	// level: An optional log level to use for the log message.
	Log(value interface{}, level int) Component

	// Run the SDK component
	Run() bool
}

Component represents a KUSANAGI SDK generic component.

type Entity

type Entity struct {
	Field      []Field
	Fields     []ObjectField
	Name       string
	Validate   bool
	Primarykey string
}

Entity definition.

func (Entity) IsEmpty

func (e Entity) IsEmpty() bool

IsEmpty checks if the entity is empty.

type Error

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

Error represents an error for a service call.

func (Error) GetAddress

func (e Error) GetAddress() string

GetAddress returns the gateway address for the service.

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) GetName

func (e Error) GetName() string

GetName returns the service name.

func (Error) GetStatus

func (e Error) GetStatus() string

GetStatus returns the status message.

func (Error) GetVersion

func (e Error) GetVersion() string

GetVersion returns the service version.

type ErrorCallback

type ErrorCallback func(error) error

ErrorCallback is called whenever an error is returned while processing a framework request in userland.

type Field

type Field struct {
	Name     string
	Type     string
	Optional bool
}

Field defines an entity field.

type File

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

File parameter.

Actions receive files thought calls to a service component. Files can also be returned from the service actions.

func NewFile

func NewFile(name, path, mimeType, filename string, size uint, token string) (*File, error)

NewFile creates a new file object.

When the path is local it can start with "file://" or be a path to a local file, otherwise it means is a remote file and it must start with "http://".

name: Name of the file parameter. path: Optional path to the file. mimeType: Optional MIME type of the file contents. filename: Optional file name and extension. size: Optional file size in bytes. token: Optional file server security token to access the file.

func (File) CopyWithMime

func (f File) CopyWithMime(mimeType string) *File

CopyWithMime creates a new file parameter with a new MIME type.

mime: MIME type of the new file parameter.

func (File) CopyWithName

func (f File) CopyWithName(name string) *File

CopyWithName creates a new file parameter with a new name.

name: Name of the new file parameter.

func (File) Exists

func (f File) Exists() bool

Exists checks if file exists.

func (File) GetFilename

func (f File) GetFilename() string

GetFilename returns the file name.

func (File) GetMime

func (f File) GetMime() string

GetMime returns the MIME type of the file contents.

func (File) GetName

func (f File) GetName() string

GetName returns the name of the file parameter.

func (File) GetPath

func (f File) GetPath() string

GetPath returns the file path.

func (File) GetSize

func (f File) GetSize() uint

GetSize returns the file size in bytes.

func (File) GetToken

func (f File) GetToken() string

GetToken returns the file server security token to access the file.

func (File) IsLocal

func (f File) IsLocal() bool

IsLocal checks if file is located in the local file system.

func (File) Read

func (f File) Read() (contents []byte, err error)

Read file's contents.

type FileSchema

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

FileSchema contains the schema definition of action file.

func (FileSchema) GetHTTPSchema

func (s FileSchema) GetHTTPSchema() *HTTPFileSchema

GetHTTPSchema returns the HTTP schema.

func (FileSchema) GetMax

func (s FileSchema) GetMax() uint

GetMax returns the maximum file size allowed for the parameter.

func (FileSchema) GetMime

func (s FileSchema) GetMime() string

GetMime returns the mime type.

func (FileSchema) GetMin

func (s FileSchema) GetMin() uint

GetMin returns the minimum file size allowed for the parameter.

func (FileSchema) GetName

func (s FileSchema) GetName() string

GetName returns the file parameter name.

func (FileSchema) IsExclusiveMax

func (s FileSchema) IsExclusiveMax() bool

IsExclusiveMax checks if the maximum size is inclusive.

func (FileSchema) IsExclusiveMin

func (s FileSchema) IsExclusiveMin() bool

IsExclusiveMax checks if the minimum size is inclusive.

func (FileSchema) IsRequired

func (s FileSchema) IsRequired() bool

IsRequired checks if the file parameter is required.

type ForeignRelation

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

ForeignRelation represent a foreign relation bwtewwn two services.

func (ForeignRelation) GetAddress

func (r ForeignRelation) GetAddress() string

GetAddress returns the gateway address for the foreign service.

func (ForeignRelation) GetForeignKeys

func (r ForeignRelation) GetForeignKeys() (fks []string)

GetForeignKeys returns the foreign key value(s) of the relation.

func (ForeignRelation) GetName

func (r ForeignRelation) GetName() string

GetName returns the name of the foreign service.

func (ForeignRelation) GetType

func (r ForeignRelation) GetType() string

GetType returns the type of the relation.

Relation type can be either "one" or "many".

type HTTPActionSchema

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

HTTPActionSchema contains the HTTP schema definition for the action.

func (HTTPActionSchema) GetBody

func (s HTTPActionSchema) GetBody() string

GetBody returns the expected MIME type of the HTTP request body for methods other than "get", "options" and "head".

func (HTTPActionSchema) GetInput

func (s HTTPActionSchema) GetInput() string

GetInput returns the default HTTP parameter location.

func (HTTPActionSchema) GetMethod

func (s HTTPActionSchema) GetMethod() string

GetMethod returns the HTTP method expected for the request to the gateway.

func (HTTPActionSchema) GetPath

func (s HTTPActionSchema) GetPath() string

GetPath returns the path to resolve to the action.

func (HTTPActionSchema) IsAccesible

func (s HTTPActionSchema) IsAccesible() bool

IsAccesible checks that the action is accesible by HTTP requests via the gateway.

type HTTPFileSchema

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

HTTPFileSchema contains the HTTP schema definition for a file.

func (HTTPFileSchema) GetParam

func (s HTTPFileSchema) GetParam() string

GetParam returns the name of the file parameter in the HTTP request.

This name can be different than the file name, and it is used in the HTTP request to submit the file contents.

func (HTTPFileSchema) IsAccesible

func (s HTTPFileSchema) IsAccesible() bool

IsAccesible checks that the file is writable by HTTP request via the gateway.

type HTTPParamSchema

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

HTTPParamSchema contains the HTTP schema definition for a parameter.

func (HTTPParamSchema) GetInput

func (s HTTPParamSchema) GetInput() string

GetInput returns the location of the parameter in the HTTP request.

func (HTTPParamSchema) GetParam

func (s HTTPParamSchema) GetParam() string

GetParam returns the name of the parameter in the HTTP request.

This name can be different than the parameter name, and it is used in the HTTP request to submit the parameter value.

func (HTTPParamSchema) IsAccesible

func (s HTTPParamSchema) IsAccesible() bool

IsAccesible checks that the parameter is writable by HTTP request via the gateway.

type HTTPRequest

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

HTTP request type.

func (HTTPRequest) GetBody

func (r HTTPRequest) GetBody() []byte

GetBody returns the HTTP request body.

func (HTTPRequest) GetFile

func (r HTTPRequest) GetFile(name string) File

GetFile returns an uploaded file.

name: The name of the file parameter.

func (HTTPRequest) GetFiles

func (r HTTPRequest) GetFiles() (files []File)

GetFiles returns all the uploaded files.

func (HTTPRequest) GetHeader

func (r HTTPRequest) GetHeader(name, preset string) string

GetHeader returns an HTTP header.

The header name is case insensitive.

name: The HTTP header name. preset: A default value to use when the header doesn't exist.

func (HTTPRequest) GetHeaderArray

func (r HTTPRequest) GetHeaderArray(name string, preset []string) []string

GetHeaderArray returns the HTTP header.

The header name is case insensitive.

name: The HTTP header name. preset: A default value to use when the header doesn't exist.

func (HTTPRequest) GetHeaders

func (r HTTPRequest) GetHeaders() map[string]string

GetHeaders returns all HTTP headers.

The first value of each header is returned when the header is present more than once in the HTTP request.

func (HTTPRequest) GetHeadersArray

func (r HTTPRequest) GetHeadersArray() map[string][]string

GetHeadersArray returns all HTTP headers.

Each header value is returned as a list.

func (HTTPRequest) GetMethod

func (r HTTPRequest) GetMethod() string

GetMethod returns the HTTP method.

func (HTTPRequest) GetPostParam

func (r HTTPRequest) GetPostParam(name, preset string) string

GetPostParam returns the param value from the HTTP POST contents.

The first value is returned when the parameter is present more than once in the HTTP request.

name: The HTTP param name. preset: A default value to use when the parmeter doesn't exist.

func (HTTPRequest) GetPostParamArray

func (r HTTPRequest) GetPostParamArray(name string, preset []string) []string

GetPostParamArray returns the param value from the HTTP POST contents.

The result is a list with all the values for the parameter. A parameter can be present more than once in an HTTP request.

name: The HTTP param name. preset: A default value to use when the parmeter doesn't exist.

func (HTTPRequest) GetPostParams

func (r HTTPRequest) GetPostParams() map[string]string

GetPostParams returns all HTTP POST params.

The first value of each parameter is returned when the parameter is present more than once in the HTTP request.

func (HTTPRequest) GetPostParamsArray

func (r HTTPRequest) GetPostParamsArray() map[string][]string

GetPostParamsArray returns all HTTP POST params.

Each parameter value is returned as a list.

func (HTTPRequest) GetProtocolVersion

func (r HTTPRequest) GetProtocolVersion() string

GetProtocolVersion returns the HTTP version.

func (HTTPRequest) GetQueryParam

func (r HTTPRequest) GetQueryParam(name, preset string) string

GetQueryParam returns the param value from the HTTP query string.

The first value is returned when the parameter is present more than once in the HTTP query string.

name: The HTTP param name. preset: A default value to use when the parmeter doesn't exist.

func (HTTPRequest) GetQueryParamArray

func (r HTTPRequest) GetQueryParamArray(name string, preset []string) []string

GetQueryParamArray returns the param value from the HTTP query string.

The result is a list with all the values for the parameter. A parameter can be present more than once in an HTTP query string.

name: The HTTP param name. preset: A default value to use when the parmeter doesn't exist.

func (HTTPRequest) GetQueryParams

func (r HTTPRequest) GetQueryParams() map[string]string

GetQueryParams returns all HTTP query params.

The first value of each parameter is returned when the parameter is present more than once in the HTTP query string.

func (HTTPRequest) GetQueryParamsArray

func (r HTTPRequest) GetQueryParamsArray() map[string][]string

GetQueryParamsArray returns all HTTP query params.

Each parameter value is returned as a list.

func (HTTPRequest) GetURL

func (r HTTPRequest) GetURL() string

GetURL returns the request's URL

func (HTTPRequest) GetURLHost

func (r HTTPRequest) GetURLHost() string

GetURLHost returns the URL hostname without port.

func (HTTPRequest) GetURLPath

func (r HTTPRequest) GetURLPath() string

GetURLPath returns the request's URL path.

func (HTTPRequest) GetURLPort

func (r HTTPRequest) GetURLPort() int

GetURLPort returns the URL port.

func (HTTPRequest) GetURLScheme

func (r HTTPRequest) GetURLScheme() string

GetURLScheme returns the URL scheme.

func (HTTPRequest) HasBody

func (r HTTPRequest) HasBody() bool

HasBody checks if the HTTP request body has content.

func (HTTPRequest) HasFile

func (r HTTPRequest) HasFile(name string) bool

HasFile checks if a file was uploaded in the current request.

name: The name of the file parameter.

func (HTTPRequest) HasHeader

func (r HTTPRequest) HasHeader(name string) bool

HasHeader checks if an HTTP header is defined.

The header name is case insensitive.

name: The HTTP header name.

func (HTTPRequest) HasPostParam

func (r HTTPRequest) HasPostParam(name string) bool

HasPostParam checks if a param is defined in the HTTP POST contents.

name: The HTTP param name.

func (HTTPRequest) HasQueryParam

func (r HTTPRequest) HasQueryParam(name string) bool

HasQueryParam checks if a param is defined in the HTTP query string.

name: The HTTP param name.

func (HTTPRequest) IsMethod

func (r HTTPRequest) IsMethod(name string) bool

IsMethod checks if the request used the given HTTP method.

name: The HTTP method name.

func (HTTPRequest) IsProtocolVersion

func (r HTTPRequest) IsProtocolVersion(version string) bool

IsProtocolVersion checks if the request used the given HTTP version.

version: The HTTP version.

type HTTPResponse

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

HTTP response type.

func (*HTTPResponse) GetBody

func (r *HTTPResponse) GetBody() []byte

GetBody returns the HTTP response body.

func (*HTTPResponse) GetHeader

func (r *HTTPResponse) GetHeader(name, preset string) string

GetHeader returns an HTTP header.

The header name is case insensitive.

name: The HTTP header name. preset: A default value to use when the header doesn't exist.

func (*HTTPResponse) GetHeaderArray

func (r *HTTPResponse) GetHeaderArray(name string, preset []string) []string

GetHeaderArray returns the HTTP header.

The header name is case insensitive.

name: The HTTP header name. preset: A default value to use when the header doesn't exist.

func (*HTTPResponse) GetHeaders

func (r *HTTPResponse) GetHeaders() map[string]string

GetHeaders returns all HTTP headers.

The first value is returned for each header.

func (*HTTPResponse) GetHeadersArray

func (r *HTTPResponse) GetHeadersArray() map[string][]string

GetHeadersArray returns all HTTP headers.

Each header value is returned as a list.

func (*HTTPResponse) GetProtocolVersion

func (r *HTTPResponse) GetProtocolVersion() string

GetProtocolVersion returns the HTTP version.

func (*HTTPResponse) GetStatus

func (r *HTTPResponse) GetStatus() string

GetStatus returns the HTTP status.

func (*HTTPResponse) GetStatusCode

func (r *HTTPResponse) GetStatusCode() int

GetStatusCode returns the HTTP status code.

func (*HTTPResponse) GetStatusText

func (r *HTTPResponse) GetStatusText() string

GetStatusText returns the HTTP status text.

func (*HTTPResponse) HasBody

func (r *HTTPResponse) HasBody() bool

HasBody checks if the HTTP response body has content.

func (*HTTPResponse) HasHeader

func (r *HTTPResponse) HasHeader(name string) bool

HasHeader checks if an HTTP header is defined.

The header name is case insensitive.

name: The HTTP header name.

func (*HTTPResponse) IsProtocolVersion

func (r *HTTPResponse) IsProtocolVersion(version string) bool

IsProtocolVersion checks if the response used the given HTTP version.

version: The HTTP version.

func (*HTTPResponse) IsStatus

func (r *HTTPResponse) IsStatus(status string) bool

IsStatus checks if the response uses the given status.

status: The HTTP status.

func (*HTTPResponse) SetBody

func (r *HTTPResponse) SetBody(content []byte) *HTTPResponse

SetBody sets the HTTP response body contents.

func (*HTTPResponse) SetHeader

func (r *HTTPResponse) SetHeader(name, value string, overwrite bool) *HTTPResponse

SetHeader sets an HTTP header with the given name and value.

name: The HTTP header. value: The header value. overwrite: Allow existing headers to be overwritten.

func (*HTTPResponse) SetProtocolVersion

func (r *HTTPResponse) SetProtocolVersion(version string) *HTTPResponse

SetProtocolVersion sets the HTTP version.

version: The HTTP version.

func (*HTTPResponse) SetStatus

func (r *HTTPResponse) SetStatus(code int, text string) *HTTPResponse

SetStatus sets the HTTP status code and text.

type HTTPServiceSchema

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

HTTPServiceSchema contains the HTTP schema definition for the service.

func (HTTPServiceSchema) IsAccesible

func (s HTTPServiceSchema) IsAccesible() bool

IsAccesible checks that the gateway has access to the service.

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

Link represents a service link.

func (Link) GetAddress

func (l Link) GetAddress() string

GetAddress returns the gateway address for the service.

func (l Link) GetLink() string

GetLink returns the link reference.

func (Link) GetName

func (l Link) GetName() string

GetName returns the service name.

func (Link) GetURI

func (l Link) GetURI() string

GetURI returns the link URI.

type Middleware

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

Middleware component.

func NewMiddleware

func NewMiddleware() *Middleware

NewMiddleware creates a new Middleware component.

func (*Middleware) Error

func (c *Middleware) Error(callback ErrorCallback) Component

func (*Middleware) GetResource

func (c *Middleware) GetResource(name string) (interface{}, error)

func (*Middleware) HasResource

func (c *Middleware) HasResource(name string) bool

func (*Middleware) Log

func (c *Middleware) Log(value interface{}, level int) Component

func (*Middleware) Request

func (m *Middleware) Request(callback RequestCallback) *Middleware

Request assigns a callback to execute when a service request is received.

callback: Callback to handle requests.

func (*Middleware) Response

func (m *Middleware) Response(callback ResponseCallback) *Middleware

Response assigns a callback to execute when a service response is received.

callback: Callback to handle responses.

func (*Middleware) Run

func (c *Middleware) Run() bool

func (*Middleware) SetResource

func (c *Middleware) SetResource(name string, factory ResourceFactory) error

func (*Middleware) Shutdown

func (c *Middleware) Shutdown(callback Callback) Component

func (*Middleware) Startup

func (c *Middleware) Startup(callback Callback) Component

type ObjectField

type ObjectField struct {
	Name     string
	Field    []Field
	Fields   []ObjectField
	Optional bool
}

ObjectField defines an entity object field.

type Param

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

Param represents an input parameter.

Actions receive parameters thought calls to a service component.

func (*Param) CopyWithName

func (p *Param) CopyWithName(name string) *Param

CopyWithName creates a copy of the parameter with a different name.

name: Name of the new parameter.

func (*Param) CopyWithType

func (p *Param) CopyWithType(type_ string) (*Param, error)

CopyWithType creates a copy of the parameter with a different type.

type: Type for the new parameter.

func (*Param) CopyWithValue

func (p *Param) CopyWithValue(value interface{}) *Param

CopyWithValue creates a copy of the parameter with a different value.

value: Value for the new parameter.

func (*Param) Exists

func (p *Param) Exists() bool

Exists checks if the parameter exists in the service call.

func (*Param) GetName

func (p *Param) GetName() string

GetName reads the name of the parameter.

func (*Param) GetType

func (p *Param) GetType() string

GetType reads the type of the parameter value.

func (*Param) GetValue

func (p *Param) GetValue() interface{}

GetValue reads the value of the parameter.

type ParamSchema

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

ParamSchema contains the schema definition of action parameters.

func (ParamSchema) AllowEmpty

func (s ParamSchema) AllowEmpty() bool

AllowEmpty checks if the parameter allows an empty value.

func (ParamSchema) GetArrayFormat

func (s ParamSchema) GetArrayFormat() string

GetArrayFormat returns the format for the parameter if the type property is set to "array".

Formats:

  • "csv" for comma separated values (default)
  • "ssv" for space separated values
  • "tsv" for tab separated values
  • "pipes" for pipe separated values
  • "multi" for multiple parameter instances instead of multiple values for a single instance.

func (ParamSchema) GetDefaultValue

func (s ParamSchema) GetDefaultValue() interface{}

GetDefaultValue returns the default value for parameter.

func (ParamSchema) GetEnum

func (s ParamSchema) GetEnum() []interface{}

GetEnum returns the set of unique values that parameter allows.

func (ParamSchema) GetFormat

func (s ParamSchema) GetFormat() string

GetFormat returns the parameter value format.

func (ParamSchema) GetHTTPSchema

func (s ParamSchema) GetHTTPSchema() *HTTPParamSchema

GetHTTPSchema returns the HTTP schema.

func (ParamSchema) GetItems

func (s ParamSchema) GetItems() map[string]interface{}

GetItems returns the JSON schema with items object definition.

func (ParamSchema) GetMax

func (s ParamSchema) GetMax() int

GetMax returns the maximum value for parameter.

func (ParamSchema) GetMaxItems

func (s ParamSchema) GetMaxItems() int

GetMaxItems returns the maximum number of items allowed for the parameter.

func (ParamSchema) GetMin

func (s ParamSchema) GetMin() int

GetMin returns the minimum value for parameter.

func (ParamSchema) GetMinItems

func (s ParamSchema) GetMinItems() int

GetMinItems returns the minimum number of items allowed for the parameter.

func (ParamSchema) GetMultipleOf

func (s ParamSchema) GetMultipleOf() int

GetMultipleOf returns the value that parameter must be divisible by.

func (ParamSchema) GetName

func (s ParamSchema) GetName() string

GetName returns the parameter name.

func (ParamSchema) GetPattern

func (s ParamSchema) GetPattern() string

GetPattern returns the ECMA 262 compliant regular expression to validate the parameter.

func (ParamSchema) GetType

func (s ParamSchema) GetType() string

GetType returns the parameter value type.

func (ParamSchema) HasDefaultValue

func (s ParamSchema) HasDefaultValue() bool

HasDefaultValue checks if parameter has a default value defined.

func (ParamSchema) HasUniqueItems

func (s ParamSchema) HasUniqueItems() bool

HasUniqueItems checks that the param must contain a set of unique items.

func (ParamSchema) IsExclusiveMax

func (s ParamSchema) IsExclusiveMax() bool

IsExclusiveMax chechs that the maximum value is inclusive.

func (ParamSchema) IsExclusiveMin

func (s ParamSchema) IsExclusiveMin() bool

IsExclusiveMin checks that minimum value is inclusive.

func (ParamSchema) IsRequired

func (s ParamSchema) IsRequired() bool

IsRequired checks if the parameter is required.

type Relation

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

Relation represents a relation between two services.

func (Relation) GetAddress

func (r Relation) GetAddress() string

GetAddress returns the gateway address for the service.

func (Relation) GetForeignRelations

func (r Relation) GetForeignRelations() (relations []ForeignRelation)

GetForeignRelations returns the relation data for the foreign services.

func (Relation) GetName

func (r Relation) GetName() string

GetName returns the name of the service.

func (Relation) GetPrimaryKey

func (r Relation) GetPrimaryKey() string

GetPrimaryKey returns the value for the primary key of the relation.

type Request

type Request struct {
	*Api
	// contains filtered or unexported fields
}

Request API type for the middleware component.

func (*Request) GetActionName

func (r *Request) GetActionName() string

GetActionName returns the name of the action.

func (*Request) GetClientAddress

func (r *Request) GetClientAddress() string

GetClientAddress returns the IP address and port of the client which sent the request.

func (*Request) GetGatewayAddress

func (r *Request) GetGatewayAddress() string

GetGatewayAddress the public gateway address.

func (*Request) GetGatewayProtocol

func (r *Request) GetGatewayProtocol() string

GetGatewayProtocol returns the protocol implemented by the gateway handling current request.

func (*Request) GetHTTPRequest

func (r *Request) GetHTTPRequest() *HTTPRequest

GetHTTPRequest returns the HTTP request semantics for the current request.

func (*Request) GetID

func (r *Request) GetID() string

GetID returns the request UUID.

func (*Request) GetParam

func (r *Request) GetParam(name string) Param

GetParam returns a request parameter.

name: The name of the parameter.

func (*Request) GetParams

func (r *Request) GetParams() (params []Param)

GetParams returns all the request's parameters.

func (*Request) GetServiceName

func (r *Request) GetServiceName() string

GetServiceName returns the name of the service.

func (*Request) GetServiceVersion

func (r *Request) GetServiceVersion() string

GetServiceVersion returns the version of the service.

func (*Request) GetTimestamp

func (r *Request) GetTimestamp() string

GetTimestamp returns the request timestamp.

func (*Request) HasParam

func (r *Request) HasParam(name string) bool

HasParam checks if a parameter exists.

name: The name of the parameter.

func (*Request) NewParam

func (r *Request) NewParam(name string, value interface{}, type_ string) (*Param, error)

NewParam creates a new parameter.

Creates an instance of Param with the given name, and optionally the value and data type. When the value is not provided then an empty string is assumed. If the data type is not defined then "string" is assumed.

name: The parameter name. value: The parameter value. type_: The data type of the value.

func (*Request) NewResponse

func (r *Request) NewResponse(code int, text string) *Response

NewResponse creates a new response.

code: Optional status code. text: Optional status text.

func (*Request) SetActionName

func (r *Request) SetActionName(name string) *Request

SetActionName sets the name of the action.

name: The name of the action.

func (*Request) SetAttribute

func (r *Request) SetAttribute(name, value string) *Request

SetAttribute registers a request attribute.

func (*Request) SetParam

func (r *Request) SetParam(p Param) *Request

SetParam adds a new param for the current request.

param: The parameter.

func (*Request) SetServiceName

func (r *Request) SetServiceName(name string) *Request

SetServiceName sets the name of the service.

name: The name of the service.

func (*Request) SetServiceVersion

func (r *Request) SetServiceVersion(version string) *Request

SetServiceVersion sets the version of the service.

version: The version of the service.

type RequestCallback

type RequestCallback func(*Request) (interface{}, error)

RequestCallback is called by middlewares when a service request is received.

The result can be either a pointer to a Request or a Response component.

type ResourceFactory

type ResourceFactory func(Component) (interface{}, error)

ResourceFactory functions create resources to be stored in a component.

The factory argument is the component that is running.

It is possible to get the specific component by casting, for example:

middleware := component.(*Middleware)

or for service components:

service := component.(*Service)

type Response

type Response struct {
	*Api
}

Response API type for the middleware component.

func (*Response) GetGatewayAddress

func (r *Response) GetGatewayAddress() string

GetGatewayAddress the public gateway address.

func (*Response) GetGatewayProtocol

func (r *Response) GetGatewayProtocol() string

GetGatewayProtocol returns the protocol implemented by the gateway handling current request.

func (*Response) GetHTTPRequest

func (r *Response) GetHTTPRequest() *HTTPRequest

GetHTTPRequest returns the HTTP request semantics for the current response.

func (*Response) GetHTTPResponse

func (r *Response) GetHTTPResponse() *HTTPResponse

GetHTTPResponse returns the HTTP response semantics for the current response.

func (*Response) GetRequestAttribute

func (r *Response) GetRequestAttribute(name, preset string) string

GetRequestAttribute retuens a request attribute value.

name: The attribute name. preset: A default value to use when the attribute doesn't exist.

func (*Response) GetRequestAttributes

func (r *Response) GetRequestAttributes() map[string]string

GetRequestAttributes returns all the request attributes.

func (*Response) GetReturn

func (r *Response) GetReturn() (interface{}, error)

GetReturn returns the value returned by the called service.

func (*Response) GetTransport

func (r *Response) GetTransport() Transport

GetTransport returns the transport.

func (*Response) HasReturn

func (r *Response) HasReturn() bool

HasReturn checks if there is a return value.

Return value is available when the initial service that is called has a return value, and returned a value in its command reply.

type ResponseCallback

type ResponseCallback func(*Response) (*Response, error)

ResponseCallback is called by middlewares when a service response is received.

type Service

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

Service component.

func NewService

func NewService() *Service

NewService creates a new Service component.

func (*Service) Action

func (s *Service) Action(name string, callback ActionCallback) *Service

Action assigns a callback to execute when a service action request is received.

func (*Service) Error

func (c *Service) Error(callback ErrorCallback) Component

func (*Service) GetResource

func (c *Service) GetResource(name string) (interface{}, error)

func (*Service) HasResource

func (c *Service) HasResource(name string) bool

func (*Service) Log

func (c *Service) Log(value interface{}, level int) Component

func (*Service) Run

func (c *Service) Run() bool

func (*Service) SetResource

func (c *Service) SetResource(name string, factory ResourceFactory) error

func (*Service) Shutdown

func (c *Service) Shutdown(callback Callback) Component

func (*Service) Startup

func (c *Service) Startup(callback Callback) Component

type ServiceData

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

ServiceData represents a service which stored data in the transport.

func (ServiceData) GetActions

func (s ServiceData) GetActions() (actions []ActionData)

GetActions returns the list of action data items for current service.

Each item represents an action on the service for which data exists.

func (ServiceData) GetAddress

func (s ServiceData) GetAddress() string

GetAddress returns the gateway address for the service.

func (ServiceData) GetName

func (s ServiceData) GetName() string

GetName returns the service name.

func (ServiceData) GetVersion

func (s ServiceData) GetVersion() string

GetVersion returns the service version.

type ServiceSchema

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

ServiceSchema contains the schema definition for a service of a specific version.

func (ServiceSchema) GetActionNames

func (s ServiceSchema) GetActionNames() (actions []string)

GetActionNames returns the names of the service actions.

func (ServiceSchema) GetActionSchema

func (s ServiceSchema) GetActionSchema(name string) (*ActionSchema, error)

GetActionSchema returns the schema for an action.

name: The action name.

func (ServiceSchema) GetAddress

func (s ServiceSchema) GetAddress() string

GetAddress returns the network address of the service.

func (ServiceSchema) GetBasePath

func (s ServiceSchema) GetBasePath() string

GetBasePath returns the base HTTP path for the service.

func (ServiceSchema) GetHTTPSchema

func (s ServiceSchema) GetHTTPSchema() *HTTPServiceSchema

GetHTTPSchema returns the HTTP schema.

func (ServiceSchema) GetName

func (s ServiceSchema) GetName() string

GetName returns the service name.

func (ServiceSchema) GetVersion

func (s ServiceSchema) GetVersion() string

GetVersion returns the service version.

func (ServiceSchema) HasAction

func (s ServiceSchema) HasAction(name string) bool

HasAction checks that an action exists in the schema.

name: The action name.

func (ServiceSchema) HasFileServer

func (s ServiceSchema) HasFileServer() bool

HasFileServer checks that the service has a files server enabled.

type Transaction

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

Transaction represents a single transaction.

func (Transaction) GetCalleeAction

func (t Transaction) GetCalleeAction() string

GetCalleeAction returns the name of the action to be called by the transaction.

func (Transaction) GetCallerAction

func (t Transaction) GetCallerAction() string

GetCallerAction returns the name of the action that registered the transaction.

func (Transaction) GetName

func (t Transaction) GetName() string

GetVersion returns the name of the service that registered the transaction.

func (Transaction) GetParams

func (t Transaction) GetParams() (params []Param)

GetParams gets the transaction parameters.

func (Transaction) GetType

func (t Transaction) GetType() string

GetType returns the transaction command type.

func (Transaction) GetVersion

func (t Transaction) GetVersion() string

GetVersion returns the version of the service that registered the transaction.

type Transport

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

Transport encapsulates the transport object.

func (Transport) GetCalls

func (t Transport) GetCalls() (callers []Caller)

GetCalls returns the service calls.

func (Transport) GetData

func (t Transport) GetData() (data []ServiceData)

GetData returns the transport data.

func (Transport) GetDownload

func (t Transport) GetDownload() (f *File)

GetDownload returns the file download registered for the response.

func (Transport) GetErrors

func (t Transport) GetErrors() (result []Error)

GetErrors returns the transport errors.

func (t Transport) GetLinks() (links []Link)

GetLinks returns the service links.

func (Transport) GetOriginDuration

func (t Transport) GetOriginDuration() uint

GetDuration returns the service execution time in milliseconds.

This time is the number of milliseconds spent by the service that was the origin of the request.

func (Transport) GetOriginService

func (t Transport) GetOriginService() []string

GetOriginService returns the origin of the request.

Result is an array containing name, version and action of the service that was the origin of the request.

func (Transport) GetProperties

func (t Transport) GetProperties() (properties map[string]string)

GetProperties returns all the userland properties.

func (Transport) GetProperty

func (t Transport) GetProperty(name, preset string) string

GetProperty returns a userland property value.

The name of the property is case sensitive.

An empty string is returned when a property with the specified name does not exist, and no default value is provided.

name: The name of the property. preset: The default value to use when the property doesn't exist.

func (Transport) GetRelations

func (t Transport) GetRelations() (relations []Relation)

GetRelations returns the service relations.

func (Transport) GetRequestID

func (t Transport) GetRequestID() string

GetRequestID returns the UUID of the request.

func (Transport) GetRequestTimestamp

func (t Transport) GetRequestTimestamp() string

GetRequestTimestamp returns the request creation timestamp.

func (Transport) GetTransactions

func (t Transport) GetTransactions(command string) ([]Transaction, error)

GetTransactions returns the transactions for a specific type.

The transaction type is case sensitive, and supports "commit", "rollback" or "complete" as value.

command: The transaction command.

func (Transport) HasDownload

func (t Transport) HasDownload() bool

HasDownload checks if a file download has been registered for the response.

Directories

Path Synopsis
lib
cli
log

Jump to

Keyboard shortcuts

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