common

package
v0.0.0-...-fda7ac9 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: Apache-2.0 Imports: 8 Imported by: 35

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddService

func AddService(sysConfig *types.SysConfig, serviceName string, serviceArea int32)

func IsNil

func IsNil(any interface{}) bool

func NewUuid

func NewUuid() string

func NewVNicConfig

func NewVNicConfig(maxDataSize uint64, txQueueSize, rxQueueSize uint64, vNetPort uint32) *types.SysConfig

func SeekResource

func SeekResource(path string, filename string) string

Types

type API

type API interface {
	Post(interface{}) IElements
	Put(interface{}) IElements
	Patch(interface{}) IElements
	Delete(interface{}) IElements
	Get(string) IElements
}

type Action

type Action byte
const (
	POST   Action = 1
	PUT    Action = 2
	PATCH  Action = 3
	DELETE Action = 4
	GET    Action = 5
	Reply  Action = 6
	Notify Action = 7
)

type IComparator

type IComparator interface {
	Left() string
	LeftProperty() IProperty
	Right() string
	RightProperty() IProperty
	Operator() string
}

type ICondition

type ICondition interface {
	Comparator() IComparator
	Operator() string
	Next() ICondition
}

type IDatatListener

type IDatatListener interface {
	ShutdownVNic(IVirtualNetworkInterface)
	HandleData([]byte, IVirtualNetworkInterface)
	Failed([]byte, IVirtualNetworkInterface, string)
}

type IElements

type IElements interface {
	Elements() []interface{}
	Keys() []interface{}
	Errors() []error
	Element() interface{}
	Query(IResources) (IQuery, error)
	Key() interface{}
	Error() error
	Serialize() ([]byte, error)
	Deserialize([]byte, IRegistry) error
}

type IExpression

type IExpression interface {
	Condition() ICondition
	Operator() string
	Next() IExpression
	Child() IExpression
}

type IInfo

type IInfo interface {
	Type() reflect.Type
	Name() string
	Serializer(SerializerMode) ISerializer
	AddSerializer(ISerializer)
	NewInstance() (interface{}, error)
}

type IIntrospector

type IIntrospector interface {
	Inspect(interface{}) (*types.RNode, error)
	Node(string) (*types.RNode, bool)
	NodeByType(p reflect.Type) (*types.RNode, bool)
	NodeByTypeName(string) (*types.RNode, bool)
	NodeByValue(interface{}) (*types.RNode, bool)
	Nodes(bool, bool) []*types.RNode
	Registry() IRegistry
	Kind(*types.RNode) reflect.Kind
	Clone(interface{}) interface{}
	TableView(string) (*types.TableView, bool)
	TableViews() []*types.TableView
}

type ILogger

type ILogger interface {
	Trace(...interface{})
	Debug(...interface{})
	Info(...interface{})
	Warning(...interface{})
	Error(...interface{}) error
	Empty() bool
	Fail(interface{}, ...interface{})
	SetLogLevel(LogLevel)
}

type IMessage

type IMessage interface {
	Source() string
	Vnet() string
	Destination() string
	ServiceArea() uint16
	ServiceName() string
	Sequence() uint32
	Priority() Priority
	Action() Action
	SetAction(Action)
	Timeout() uint16
	Request() bool
	Reply() bool
	FailMessage() string
	Data() string
	SetData(string)
	Tr() ITransaction
	SetTr(transaction ITransaction)
}

type IProperty

type IProperty interface {
	PropertyId() (string, error)
	Get(interface{}) (interface{}, error)
	Set(interface{}, interface{}) (interface{}, interface{}, error)
	Node() *types.RNode
	Parent() IProperty
	IsString() bool
}

type IQuery

type IQuery interface {
	RootType() *types.RNode
	Properties() []IProperty
	Criteria() IExpression
}

type IRegistry

type IRegistry interface {
	//Register - receive as an input an instance and register, extract the Type and register it.
	Register(interface{}) (bool, error)
	//RegisterType - receive a reflect.Type instance and register it.
	RegisterType(reflect.Type) (bool, error)
	//Info Retrieve the registered entry for this type.
	Info(string) (IInfo, error)
	//Register Enum string to int32 values
	RegisterEnums(map[string]int32)
	//Get int32 value of an enum
	Enum(string) int32
}

IRegistry - Interface for encapsulating a Type registry service so a struct instance can be instantiated based on the type name.

type IResources

type IResources interface {
	Registry() IRegistry
	ServicePoints() IServicePoints
	Security() ISecurityProvider
	DataListener() IDatatListener
	Serializer(SerializerMode) ISerializer
	Logger() ILogger
	SysConfig() *types.SysConfig
	Introspector() IIntrospector
	AddService(string, int32)
}

type ISecurityProvider

type ISecurityProvider interface {
	CanDial(string, uint32) (net.Conn, error)
	CanAccept(net.Conn) error
	ValidateConnection(net.Conn, *types.SysConfig) error

	Encrypt([]byte) (string, error)
	Decrypt(string) ([]byte, error)

	CanDoAction(Action, IElements, string, string, ...string) error
	ScopeView(IElements, string, string, ...string) IElements
	Authenticate(string, string, ...string) string
}

func LoadSecurityProvider

func LoadSecurityProvider(soFileName string) (ISecurityProvider, error)

type ISerializer

type ISerializer interface {
	Mode() SerializerMode
	Marshal(interface{}, IRegistry) ([]byte, error)
	Unmarshal([]byte, IRegistry) (interface{}, error)
}

type IServicePointHandler

type IServicePointHandler interface {
	Post(IElements, IResources) IElements
	Put(IElements, IResources) IElements
	Patch(IElements, IResources) IElements
	Delete(IElements, IResources) IElements
	GetCopy(IElements, IResources) IElements
	Get(IElements, IResources) IElements
	Failed(IElements, IResources, IMessage) IElements
	ServiceName() string
	ServiceModel() IElements
	EndPoint() string
	Transactional() bool
	ReplicationCount() int
	ReplicationScore() int
}

type IServicePoints

type IServicePoints interface {
	// Register A Service Point, handler + service area
	RegisterServicePoint(IServicePointHandler, uint16) error
	// Handle a message and forward to the handler
	Handle(IElements, Action, IVirtualNetworkInterface, IMessage, bool) IElements
	// Handle a notification message, massage it to a change set and forward to the handler
	Notify(IElements, IVirtualNetworkInterface, IMessage, bool) IElements
	// Return the service point handler for the service name and area
	ServicePointHandler(string, uint16) (IServicePointHandler, bool)
}

Add a bool for transaction

type ITransaction

type ITransaction interface {
	Id() string
	State() TransactionState
	SetState(TransactionState)
	ErrorMessage() string
	SetErrorMessage(string)
	StartTime() int64
}

type IVirtualNetworkInterface

type IVirtualNetworkInterface interface {
	Start()
	Shutdown()
	Name() string
	SendMessage([]byte) error
	// Unicast a message without expecting response
	Unicast(string, string, uint16, Action, interface{}) error
	// Unicast a message expecting response
	Request(string, string, uint16, Action, interface{}) IElements
	// Reply to a Request
	Reply(IMessage, IElements) error
	// Multicast a message to all service name listeners, without expecting a response
	Multicast(string, uint16, Action, interface{}) error
	// Single a message to ONLY ONE service provider of the group,
	// not expecting a response. Provider is chosen by residency to the requester.
	Single(string, uint16, Action, interface{}) error
	// SingleRequest same as single but expecting a response
	SingleRequest(string, uint16, Action, interface{}) IElements
	// Leader Same as SingleRequest but sending always to the leader.
	Leader(string, uint16, Action, interface{}) IElements
	Forward(IMessage, string) IElements
	API(string, uint16) API
	Resources() IResources
}

type LogLevel

type LogLevel int
const (
	Trace_Level   LogLevel = 1
	Debug_Level   LogLevel = 2
	Info_Level    LogLevel = 3
	Warning_Level LogLevel = 4
	Error_Level   LogLevel = 5
)

func (LogLevel) String

func (l LogLevel) String() string

type Priority

type Priority byte
const (
	P8 Priority = 0
	P7 Priority = 1
	P6 Priority = 2
	P5 Priority = 3
	P4 Priority = 4
	P3 Priority = 5
	P2 Priority = 6
	P1 Priority = 7
)

type SerializerMode

type SerializerMode int
const (
	BINARY SerializerMode = 1
	JSON   SerializerMode = 2
	STRING SerializerMode = 3
)

type TransactionState

type TransactionState uint8
const (
	Create     TransactionState = 1
	Created    TransactionState = 2
	Start      TransactionState = 3
	Lock       TransactionState = 4
	Locked     TransactionState = 5
	LockFailed TransactionState = 6
	Commit     TransactionState = 7
	Commited   TransactionState = 8
	Rollback   TransactionState = 9
	Rollbacked TransactionState = 10
	Finish     TransactionState = 11
	Finished   TransactionState = 12
	Errored    TransactionState = 13
)

func (TransactionState) String

func (t TransactionState) String() string

Jump to

Keyboard shortcuts

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