model

package
v0.0.0-...-df03e99 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Session Context Key
	ContextSessionKey = ContextKey("session-key")
	// Session Context Auth Token
	ContextKeyAuthtoken = ContextKey("auth-token")
	// Session Context Remote Address
	ContextRemoteAddress = ContextKey("remote-address")
)

Functions

func GenerateSecureToken

func GenerateSecureToken(length int) string

Generate a Security Token of a given length

func SubmitFaiure

func SubmitFaiure(w http.ResponseWriter, statusCode int, message string)

Submit Failure Data To the client

func SubmitSuccess

func SubmitSuccess(w http.ResponseWriter, message string)

Submit Success Data To the client

Types

type ApiAction

type ApiAction interface {
	// Execute API command with API given arguments
	With(context.ApiCallContext) ApiAction
	Do() error
}

Interface that describes the callback action of an API call

type ApiActionFunction

type ApiActionFunction func(context.ApiCallContext) error

Describe execution function for API rest connections

type ApiCallHandler

type ApiCallHandler interface {
	// Returns the list of managed Web Methods [GET, POST, PUT, DELETE, ...]
	Methods() []string
	// Handle Request using http.Request, http.ResponseWriter
	HandleRequest(http.ResponseWriter, *http.Request)
	// Returns the path filter for this https call handler
	GetPath() string
	// Set reference to server map or leave map nil, if not used
	SetServerMap(m *map[string]interface{})
	// Set the server logger
	SetLogger(logger log.Logger)
}

Defines an handler for all methods in a request

type ApiClient

type ApiClient interface {
	// Configures a new Connection using server base path
	Connect(config ClientConfig) error
	// Makes a call
	// Requests must be sent to the body Reader (preferred: bytes.Buffer)
	Call(path string, method string, contentType *encoding.MimeType, accepts *encoding.MimeType, body io.Reader) (*http.Response, error)
	// Makes a call
	// Requests must be sent and object with preferred encoding configuration
	Encode(path string, method string, contentType encoding.MimeType, accepts *encoding.MimeType, request interface{}, response interface{}) error
}

Describes an API Client most features

type ApiServer

type ApiServer interface {
	// Creates server configuration, and setup the network properties.
	// It raises exception if the server is already running.
	Init(config ServerConfig) (ApiServer, error)
	// Starts API Server and serve requests
	Start() error
	// Stops API Server and stop requests
	Stop() error
	// Verifies API Server is running
	Running() bool
	// Verifies API Server is running
	Working() bool
	// Waits for API server is down
	Wait()
	// Add a new path call handler in the api router, allowing management of multiple
	// mime types and methods calls for the same path requested by the client
	// It raises exception if the API call handler has not method call handling function
	// or if the Path is duplicate
	AddPath(ApiCallHandler) error
}

Describes an API Server most features

type ClientConfig

type ClientConfig struct {
	// Communication protocol (eg.: http, https, ...)
	Protocol string
	// Host name or ip address (eg. my-host.acme.com or 192.168.1.222)
	Host string
	// Remote API Server Port
	Port int
	// Remote API Server connection timeout (0 means not set)
	Timeout time.Duration
	// Remote API Server Security Configuration
	Config *tls.Config
}

Describe client connection properties

type ContextKey

type ContextKey string

Context Key Type

func (ContextKey) String

func (c ContextKey) String() string

type MessageQueue

type MessageQueue chan interface{} // Describe a single peer node message item

Message Queue that allows messages to flow between components

type PipeMessage

type PipeMessage []byte

Default Message type

type PipeNode

type PipeNode interface {
	// Creates pipe node configuration, and setup the network properties.
	// It raises exception if the server is already running.
	Init(config PipeNodeConfig) (PipeNode, error)
	// Starts Pipe Node and serve requests
	Type() PipeType
	// Starts Pipe Node and serve requests
	Start() error
	// Stops Pipe Node and stop requests
	Stop() error
	// Verify Pipe Node is running
	Running() bool
	// Wait for Pipe Node is down
	Wait()
	// Wait for Pipe Node is started an output channel  (for Input or Input/Output Pipe mode nodes)
	UntilStarted()
	// Collects a message input channel (for Output or Input/Output Pipe mode nodes)
	GetOutputPipeChannel() chan<- PipeMessage
	// Collects a message output channel (for Input or Input/Output Pipe mode nodes)
	GetInputPipeChannel() <-chan PipeMessage
}

Describes an Pipe Node most features

type PipeNodeConfig

type PipeNodeConfig struct {
	// Connection network type (default: tcp)
	Network string
	// Input Host name or ip address (eg. my-host.acme.com or 127,0,0,1 or empty or 0.0.0.0)
	InHost string
	// Input Pipe Node Port
	InPort int
	// Output Host name or ip address (eg. my-host.acme.com or 127,0,0,1 or empty or 0.0.0.0)
	OutHost string
	// Input Pipe Node Port
	OutPort int
	// Pipe Node type
	Type PipeType
	// Pipe Node Security Configuration
	Config *tls.Config
}

Describe pine node properties

type PipeType

type PipeType byte
const (
	// Input stream pipe
	NoTypeSelected PipeType = 0
	// Input stream pipe
	InputPipe PipeType = iota + 1
	// Output stream pipe
	OutputPipe
	// Input and Output streams pipe
	InputOutputPipe
)

type ServerConfig

type ServerConfig struct {
	// Host name or ip address (eg. my-host.acme.com or 127,0,0,1 or empty or 0.0.0.0)
	Host string
	// API Server Port
	Port int
	// API Server Security Configuration
	Config *tls.Config
	// TLS Certificate file Full Path
	CertPath string
	// TLS Certificate Key file Full Path
	KeyPath string
}

Describe server connection properties

type TcpAction

type TcpAction interface {
	GetName() string
	// Execute Tcp command with API given arguments
	With(context.TcpContext) TcpAction
	Do() error
}

Interface that describes the callback action of an Tcp request

type TcpActionFunction

type TcpActionFunction func(context.TcpContext) error

Describe execution function for tcp connections

type TcpCallHandler

type TcpCallHandler interface {
	// Returns the list of managed actions names
	Names() []string
	// Handle Request using net.Conn
	HandleRequest(net.Conn, stream.ConnReaderWriterCloser)
	// Returns the handler name
	GetName() string
	// Set reference to server map or leave map nil, if not used
	SetServerMap(m *map[string]interface{})
	// Set the server logger
	SetLogger(logger log.Logger)
	// Set encoding used by the server
	SetEncoding(enc encoding.Encoding)
}

Defines an handler for an multiple actionsin a request

type TcpClient

type TcpClient interface {
	// Configure a new Connection using server base path
	Connect(config TcpClientConfig) error
	// Close client connection
	Close() error
	// check if client connection is open
	IsOpen() bool
	// Make a call
	// Request must be sent to the body Reader (preferred: bytes.Buffer)
	Send(body io.Reader, response interface{}, timeout time.Duration) error
	// Make a call
	// Request must be sent and object with preferred encoding configuration
	Encode(request interface{}, response interface{}, timeout time.Duration) error
	// Wait for a client answer, for the maximum timeout of forever in case the timeout is zero
	ReadRemote(timeout time.Duration, response interface{}) error
}

Describes an Tcp Client most features

type TcpClientConfig

type TcpClientConfig struct {
	// Connection network type (default: tcp)
	Network string
	// Host name or ip address (eg. my-host.acme.com or 192.168.1.222)
	Host string
	// Remote Tcp Server Port
	Port int
	// Remote Tcp Server connection timeout (0 means not set)
	Timeout time.Duration
	// Remote Tcp Server Security Configuration
	Config *tls.Config
	// Encoding
	Encoding encoding.Encoding
}

Describe client connection properties

type TcpServer

type TcpServer interface {
	// Creates server configuration, and setup the network properties.
	// It raises exception if the server is already running.
	Init(config TcpServerConfig) (TcpServer, error)
	// Starts Tcp Server and serve requests
	Start() error
	// Stops Tcp Server and stop requests
	Stop() error
	// Verifies Tcp Server is running
	Running() bool
	// Verifies Tcp Server is running
	Working() bool
	// Waits for Tcp server is down
	Wait()
	// Add a new path call handler in the api router, allowing management of multiple
	// mime types and methods calls for the same path requested by the client
	// It raises exception if the API call handler has not method call handling function
	// or if the Path is duplicate
	AddPath(TcpCallHandler) error
}

Describes an Tcp Server most features

type TcpServerConfig

type TcpServerConfig struct {
	// Connection network type (default: tcp)
	Network string
	// Host name or ip address (eg. my-host.acme.com or 127,0,0,1 or empty or 0.0.0.0)
	Host string
	// Tcp Server Port
	Port int
	// Tcp Server Security Configuration
	Config *tls.Config
	// Encoding
	Encoding encoding.Encoding
}

Describe server connection properties

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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