Documentation ¶
Index ¶
- Constants
- type Action
- func (a *Action) Call(service string, version string, action string, params []Param, files []File, ...) (interface{}, error)
- func (a *Action) Commit(action string, params []Param) (*Action, error)
- func (a *Action) Complete(action string, params []Param) (*Action, error)
- func (a *Action) DeferCall(service, version, action string, params []Param, files []File) (*Action, error)
- func (a *Action) Error(message string, code int, status string) *Action
- func (a *Action) GetActionName() string
- func (a *Action) GetFile(name string) File
- func (a *Action) GetFiles() (files []File)
- func (a *Action) GetParam(name string) Param
- func (a *Action) GetParams() (params []Param)
- func (a *Action) HasFile(name string) bool
- func (a *Action) HasParam(name string) bool
- func (a *Action) IsOrigin() bool
- func (a *Action) NewFile(name, path, mimeType string) (*File, error)
- func (a *Action) NewParam(name string, value interface{}, type_ string) (*Param, error)
- func (a *Action) RelateMany(pk, service string, fks []string) (*Action, error)
- func (a *Action) RelateManyRemote(pk, address, service string, fks []string) (*Action, error)
- func (a *Action) RelateOne(pk, service, fk string) (*Action, error)
- func (a *Action) RelateOneRemote(pk, address, service, fk string) (*Action, error)
- func (a *Action) RemoteCall(address string, service string, version string, action string, params []Param, ...) (*Action, error)
- func (a *Action) Rollback(action string, params []Param) (*Action, error)
- func (a *Action) SetCollection(collection []map[string]interface{}) *Action
- func (a *Action) SetDownload(f File) (*Action, error)
- func (a *Action) SetEntity(entity map[string]interface{}) *Action
- func (a *Action) SetLink(link, uri string) (*Action, error)
- func (a *Action) SetProperty(name, value string) *Action
- func (a *Action) SetReturn(value interface{}) (*Action, error)
- type ActionCallback
- type ActionData
- type ActionSchema
- func (s ActionSchema) GetCalls() (calls [][]string)
- func (s ActionSchema) GetDeferCalls() (calls [][]string)
- func (s ActionSchema) GetEntity() *Entity
- func (s ActionSchema) GetEntityPath() string
- func (s ActionSchema) GetFileSchema(name string) (*FileSchema, error)
- func (s ActionSchema) GetFiles() (files []string)
- func (s ActionSchema) GetHTTPSchema() *HTTPActionSchema
- func (s ActionSchema) GetName() string
- func (s ActionSchema) GetParamSchema(name string) (*ParamSchema, error)
- func (s ActionSchema) GetParams() (params []string)
- func (s ActionSchema) GetPathDelimiter() string
- func (s ActionSchema) GetRelations() (relations [][]string)
- func (s ActionSchema) GetRemoteCalls() (calls [][]string)
- func (s ActionSchema) GetReturnType() (string, error)
- func (s ActionSchema) GetTags() (tags []string)
- func (s ActionSchema) GetTimeout() uint
- func (s ActionSchema) HasCall(name, version, action string) bool
- func (s ActionSchema) HasCalls() bool
- func (s ActionSchema) HasDeferCall(name, version, action string) bool
- func (s ActionSchema) HasDeferCalls() bool
- func (s ActionSchema) HasEntity() bool
- func (s ActionSchema) HasFile(name string) bool
- func (s ActionSchema) HasParam(name string) bool
- func (s ActionSchema) HasRelations() bool
- func (s ActionSchema) HasRemoteCall(address, name, version, action string) bool
- func (s ActionSchema) HasRemoteCalls() bool
- func (s ActionSchema) HasReturn() bool
- func (s ActionSchema) HasTag(name string) bool
- func (s ActionSchema) IsCollection() bool
- func (s ActionSchema) IsDeprecated() bool
- func (s ActionSchema) ResolveEntity(data map[string]interface{}) (map[string]interface{}, error)
- type Api
- func (a *Api) Done() bool
- func (a *Api) GetAsyncContext() context.Context
- func (a *Api) GetFrameworkVersion() string
- func (a *Api) GetName() string
- func (a *Api) GetPath() string
- func (a *Api) GetResource(name string) (interface{}, error)
- func (a *Api) GetServiceSchema(name, version string) (*ServiceSchema, error)
- func (a *Api) GetServices() []payload.ServiceVersion
- func (a *Api) GetVariable(name string) string
- func (a *Api) GetVariables() map[string]string
- func (a *Api) GetVersion() string
- func (a *Api) HasResource(name string) bool
- func (a *Api) HasVariable(name string) bool
- func (a *Api) IsDebug() bool
- func (a *Api) Log(value interface{}, level int) (*Api, error)
- type Callback
- type Callee
- type Caller
- type Component
- type Entity
- type Error
- type ErrorCallback
- type Field
- type File
- func (f File) CopyWithMime(mimeType string) *File
- func (f File) CopyWithName(name string) *File
- func (f File) Exists() bool
- func (f File) GetFilename() string
- func (f File) GetMime() string
- func (f File) GetName() string
- func (f File) GetPath() string
- func (f File) GetSize() uint
- func (f File) GetToken() string
- func (f File) IsLocal() bool
- func (f File) Read() (contents []byte, err error)
- type FileSchema
- func (s FileSchema) GetHTTPSchema() *HTTPFileSchema
- func (s FileSchema) GetMax() uint
- func (s FileSchema) GetMime() string
- func (s FileSchema) GetMin() uint
- func (s FileSchema) GetName() string
- func (s FileSchema) IsExclusiveMax() bool
- func (s FileSchema) IsExclusiveMin() bool
- func (s FileSchema) IsRequired() bool
- type ForeignRelation
- type HTTPActionSchema
- type HTTPFileSchema
- type HTTPParamSchema
- type HTTPRequest
- func (r HTTPRequest) GetBody() []byte
- func (r HTTPRequest) GetFile(name string) File
- func (r HTTPRequest) GetFiles() (files []File)
- func (r HTTPRequest) GetHeader(name, preset string) string
- func (r HTTPRequest) GetHeaderArray(name string, preset []string) []string
- func (r HTTPRequest) GetHeaders() map[string]string
- func (r HTTPRequest) GetHeadersArray() map[string][]string
- func (r HTTPRequest) GetMethod() string
- func (r HTTPRequest) GetPostParam(name, preset string) string
- func (r HTTPRequest) GetPostParamArray(name string, preset []string) []string
- func (r HTTPRequest) GetPostParams() map[string]string
- func (r HTTPRequest) GetPostParamsArray() map[string][]string
- func (r HTTPRequest) GetProtocolVersion() string
- func (r HTTPRequest) GetQueryParam(name, preset string) string
- func (r HTTPRequest) GetQueryParamArray(name string, preset []string) []string
- func (r HTTPRequest) GetQueryParams() map[string]string
- func (r HTTPRequest) GetQueryParamsArray() map[string][]string
- func (r HTTPRequest) GetURL() string
- func (r HTTPRequest) GetURLHost() string
- func (r HTTPRequest) GetURLPath() string
- func (r HTTPRequest) GetURLPort() int
- func (r HTTPRequest) GetURLScheme() string
- func (r HTTPRequest) HasBody() bool
- func (r HTTPRequest) HasFile(name string) bool
- func (r HTTPRequest) HasHeader(name string) bool
- func (r HTTPRequest) HasPostParam(name string) bool
- func (r HTTPRequest) HasQueryParam(name string) bool
- func (r HTTPRequest) IsMethod(name string) bool
- func (r HTTPRequest) IsProtocolVersion(version string) bool
- type HTTPResponse
- func (r *HTTPResponse) GetBody() []byte
- func (r *HTTPResponse) GetHeader(name, preset string) string
- func (r *HTTPResponse) GetHeaderArray(name string, preset []string) []string
- func (r *HTTPResponse) GetHeaders() map[string]string
- func (r *HTTPResponse) GetHeadersArray() map[string][]string
- func (r *HTTPResponse) GetProtocolVersion() string
- func (r *HTTPResponse) GetStatus() string
- func (r *HTTPResponse) GetStatusCode() int
- func (r *HTTPResponse) GetStatusText() string
- func (r *HTTPResponse) HasBody() bool
- func (r *HTTPResponse) HasHeader(name string) bool
- func (r *HTTPResponse) IsProtocolVersion(version string) bool
- func (r *HTTPResponse) IsStatus(status string) bool
- func (r *HTTPResponse) SetBody(content []byte) *HTTPResponse
- func (r *HTTPResponse) SetHeader(name, value string, overwrite bool) *HTTPResponse
- func (r *HTTPResponse) SetProtocolVersion(version string) *HTTPResponse
- func (r *HTTPResponse) SetStatus(code int, text string) *HTTPResponse
- type HTTPServiceSchema
- type Link
- type Middleware
- func (c *Middleware) Error(callback ErrorCallback) Component
- func (c *Middleware) GetResource(name string) (interface{}, error)
- func (c *Middleware) HasResource(name string) bool
- func (c *Middleware) Log(value interface{}, level int) Component
- func (m *Middleware) Request(callback RequestCallback) *Middleware
- func (m *Middleware) Response(callback ResponseCallback) *Middleware
- func (c *Middleware) Run() bool
- func (c *Middleware) SetResource(name string, factory ResourceFactory) error
- func (c *Middleware) Shutdown(callback Callback) Component
- func (c *Middleware) Startup(callback Callback) Component
- type ObjectField
- type Param
- type ParamSchema
- func (s ParamSchema) AllowEmpty() bool
- func (s ParamSchema) GetArrayFormat() string
- func (s ParamSchema) GetDefaultValue() interface{}
- func (s ParamSchema) GetEnum() []interface{}
- func (s ParamSchema) GetFormat() string
- func (s ParamSchema) GetHTTPSchema() *HTTPParamSchema
- func (s ParamSchema) GetItems() map[string]interface{}
- func (s ParamSchema) GetMax() int
- func (s ParamSchema) GetMaxItems() int
- func (s ParamSchema) GetMin() int
- func (s ParamSchema) GetMinItems() int
- func (s ParamSchema) GetMultipleOf() int
- func (s ParamSchema) GetName() string
- func (s ParamSchema) GetPattern() string
- func (s ParamSchema) GetType() string
- func (s ParamSchema) HasDefaultValue() bool
- func (s ParamSchema) HasUniqueItems() bool
- func (s ParamSchema) IsExclusiveMax() bool
- func (s ParamSchema) IsExclusiveMin() bool
- func (s ParamSchema) IsRequired() bool
- type Relation
- type Request
- func (r *Request) GetActionName() string
- func (r *Request) GetClientAddress() string
- func (r *Request) GetGatewayAddress() string
- func (r *Request) GetGatewayProtocol() string
- func (r *Request) GetHTTPRequest() *HTTPRequest
- func (r *Request) GetID() string
- func (r *Request) GetParam(name string) Param
- func (r *Request) GetParams() (params []Param)
- func (r *Request) GetServiceName() string
- func (r *Request) GetServiceVersion() string
- func (r *Request) GetTimestamp() string
- func (r *Request) HasParam(name string) bool
- func (r *Request) NewParam(name string, value interface{}, type_ string) (*Param, error)
- func (r *Request) NewResponse(code int, text string) *Response
- func (r *Request) SetActionName(name string) *Request
- func (r *Request) SetAttribute(name, value string) *Request
- func (r *Request) SetParam(p Param) *Request
- func (r *Request) SetServiceName(name string) *Request
- func (r *Request) SetServiceVersion(version string) *Request
- type RequestCallback
- type ResourceFactory
- type Response
- func (r *Response) GetGatewayAddress() string
- func (r *Response) GetGatewayProtocol() string
- func (r *Response) GetHTTPRequest() *HTTPRequest
- func (r *Response) GetHTTPResponse() *HTTPResponse
- func (r *Response) GetRequestAttribute(name, preset string) string
- func (r *Response) GetRequestAttributes() map[string]string
- func (r *Response) GetReturn() (interface{}, error)
- func (r *Response) GetTransport() Transport
- func (r *Response) HasReturn() bool
- type ResponseCallback
- type Service
- func (s *Service) Action(name string, callback ActionCallback) *Service
- func (c *Service) Error(callback ErrorCallback) Component
- func (c *Service) GetResource(name string) (interface{}, error)
- func (c *Service) HasResource(name string) bool
- func (c *Service) Log(value interface{}, level int) Component
- func (c *Service) Run() bool
- func (c *Service) SetResource(name string, factory ResourceFactory) error
- func (c *Service) Shutdown(callback Callback) Component
- func (c *Service) Startup(callback Callback) Component
- type ServiceData
- type ServiceSchema
- func (s ServiceSchema) GetActionNames() (actions []string)
- func (s ServiceSchema) GetActionSchema(name string) (*ActionSchema, error)
- func (s ServiceSchema) GetAddress() string
- func (s ServiceSchema) GetBasePath() string
- func (s ServiceSchema) GetHTTPSchema() *HTTPServiceSchema
- func (s ServiceSchema) GetName() string
- func (s ServiceSchema) GetVersion() string
- func (s ServiceSchema) HasAction(name string) bool
- func (s ServiceSchema) HasFileServer() bool
- type Transaction
- type Transport
- func (t Transport) GetCalls() (callers []Caller)
- func (t Transport) GetData() (data []ServiceData)
- func (t Transport) GetDownload() (f *File)
- func (t Transport) GetErrors() (result []Error)
- func (t Transport) GetLinks() (links []Link)
- func (t Transport) GetOriginDuration() uint
- func (t Transport) GetOriginService() []string
- func (t Transport) GetProperties() (properties map[string]string)
- func (t Transport) GetProperty(name, preset string) string
- func (t Transport) GetRelations() (relations []Relation)
- func (t Transport) GetRequestID() string
- func (t Transport) GetRequestTimestamp() string
- func (t Transport) GetTransactions(command string) ([]Transaction, error)
- func (t Transport) HasDownload() bool
Constants ¶
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.
const ArrayFormatMulti = "multi"
const ArrayFormatPipe = "pipe"
const ArrayFormatSSV = "ssv"
const ArrayFormatTSV = "tsv"
const Commit = payload.TransactionCommit
Transaction commands
const Complete = payload.TransactionComplete
const ExecutionTimeout = 30000
ExecutionTimeout defines the number of milliseconds to wait by default when an action is executed.
const RelationTypeMany = "many"
const RelationTypeOne = "one"
Types of relations between two services.
const Rollback = payload.TransactionRollback
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 ¶
Commit registers a transaction to be called when request succeeds.
action: The action name. params: Optional list of parameters.
func (*Action) Complete ¶
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 ¶
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 ¶
GetActionName returns the name of the action.
func (*Action) HasFile ¶
HasFile checks if a file was provided for the action.
name: The name of the file parameter.
func (*Action) NewFile ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Rollback registers a transaction to be called when request fails.
action: The action name. params: Optional list of parameters.
func (*Action) SetCollection ¶
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) SetEntity ¶
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 (*Action) SetLink ¶
SetLink sets a link for the given URI.
link: The link name. uri: The link URI.
func (*Action) SetProperty ¶
SetProperty sets a userland property in the transport.
name: The property name. value: The property value.
type ActionCallback ¶
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) GetAsyncContext ¶
GetAsyncContext return the context for the current request.
func (*Api) GetFrameworkVersion ¶
GetFrameworkVersion gets the KUSANAGI framework version.
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) GetVariables ¶
Gets all component variables.
type Callee ¶
type Callee struct {
// contains filtered or unexported fields
}
Callee represents a service being called by another service.
func (Callee) GetAddress ¶
GetAddress returns the public gateway address for calls to another realm.
func (Callee) GetDuration ¶
GetDuration returns the duration of the call in milliseconds.
func (Callee) GetTimeout ¶
GetTimeout returns the timeout in milliseconds for a call to a service in another realm.
func (Callee) GetVersion ¶
GetVersion returns the version of the service being called.
type Caller ¶
type Caller struct {
// contains filtered or unexported fields
}
Caller represents a service which registered call in the transport.
func (Caller) GetVersion ¶
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.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents an error for a service call.
func (Error) GetAddress ¶
GetAddress returns the gateway address for the service.
func (Error) GetVersion ¶
GetVersion returns the service version.
type ErrorCallback ¶
ErrorCallback is called whenever an error is returned while processing a framework request in userland.
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 ¶
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 ¶
CopyWithMime creates a new file parameter with a new MIME type.
mime: MIME type of the new file parameter.
func (File) CopyWithName ¶
CopyWithName creates a new file parameter with a new name.
name: Name of the new file parameter.
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) 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) 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 ¶
type Link struct {
// contains filtered or unexported fields
}
Link represents a service link.
func (Link) GetAddress ¶
GetAddress returns the gateway address for the service.
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 (*Middleware) HasResource ¶
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) SetResource ¶
func (c *Middleware) SetResource(name string, factory ResourceFactory) error
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 ¶
CopyWithName creates a copy of the parameter with a different name.
name: Name of the new parameter.
func (*Param) CopyWithType ¶
CopyWithType creates a copy of the parameter with a different type.
type: Type for the new parameter.
func (*Param) CopyWithValue ¶
CopyWithValue creates a copy of the parameter with a different value.
value: Value for the new 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 ¶
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) GetPrimaryKey ¶
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 ¶
GetActionName returns the name of the action.
func (*Request) GetClientAddress ¶
GetClientAddress returns the IP address and port of the client which sent the request.
func (*Request) GetGatewayAddress ¶
GetGatewayAddress the public gateway address.
func (*Request) GetGatewayProtocol ¶
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) GetServiceName ¶
GetServiceName returns the name of the service.
func (*Request) GetServiceVersion ¶
GetServiceVersion returns the version of the service.
func (*Request) GetTimestamp ¶
GetTimestamp returns the request timestamp.
func (*Request) NewParam ¶
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 ¶
NewResponse creates a new response.
code: Optional status code. text: Optional status text.
func (*Request) SetActionName ¶
SetActionName sets the name of the action.
name: The name of the action.
func (*Request) SetAttribute ¶
SetAttribute registers a request attribute.
func (*Request) SetServiceName ¶
SetServiceName sets the name of the service.
name: The name of the service.
func (*Request) SetServiceVersion ¶
SetServiceVersion sets the version of the service.
version: The version of the service.
type RequestCallback ¶
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 ¶
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 ¶
GetGatewayAddress the public gateway address.
func (*Response) GetGatewayProtocol ¶
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 ¶
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 ¶
GetRequestAttributes returns all the request attributes.
func (*Response) GetTransport ¶
GetTransport returns the transport.
type ResponseCallback ¶
ResponseCallback is called by middlewares when a service response is received.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
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 (*Service) HasResource ¶
func (*Service) SetResource ¶
func (c *Service) SetResource(name string, factory ResourceFactory) error
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) GetData ¶
func (t Transport) GetData() (data []ServiceData)
GetData returns the transport data.
func (Transport) GetDownload ¶
GetDownload returns the file download registered for the response.
func (Transport) GetOriginDuration ¶
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 ¶
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 ¶
GetProperties returns all the userland properties.
func (Transport) GetProperty ¶
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 ¶
GetRelations returns the service relations.
func (Transport) GetRequestID ¶
GetRequestID returns the UUID of the request.
func (Transport) GetRequestTimestamp ¶
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 ¶
HasDownload checks if a file download has been registered for the response.