common

package
v0.0.0-...-c92cbe1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 25 Imported by: 1

README

Package common

Contains all packages interfaces, global data & helper methods. The convention is, _interfaces or _helpers.

Documentation

Index

Constants

View Source
const (
	RECKEY = "_RK_"
)

Variables

View Source
var JsonMarshalOptions = protojson.MarshalOptions{
	EmitUnpopulated: true,
	Multiline:       true,
}
View Source
var NetConfig = &model.NetConfig{
	MaxDataSize:        1024 * 1024,
	DefaultTxQueueSize: 1000,
	DefaultRxQueueSize: 1000,
	DefaultSwitchPort:  50000,
}

Functions

func Bytes2Long

func Bytes2Long(data []byte) int64

func CreateCA

func CreateCA(filenamePrefix, org, country, county, city, street, zipcode, email string, years int) (*x509.Certificate, *rsa.PrivateKey, error)

func CreateCrt

func CreateCrt(filenamePrefix, org, country, county, city, street, zipcode, email, ip, secret string, port int64, years int, ca *x509.Certificate, caKey *rsa.PrivateKey) error

func CreateDefaultTestCertificate

func CreateDefaultTestCertificate() error

func Decrypt

func Decrypt(stringToDecode, key string) ([]byte, error)

func DeepDecorator

func DeepDecorator(node *model.Node) bool

func Encrypt

func Encrypt(dataToEncode []byte, key string) (string, error)

func GenerateAES256Key

func GenerateAES256Key() string

func IgnoreName

func IgnoreName(fieldName string) bool

func IsLeaf

func IsLeaf(node *model.Node) bool

func IsRoot

func IsRoot(node *model.Node) bool

func Long2Bytes

func Long2Bytes(s int64) []byte

func NodeKey

func NodeKey(instanceId string) string

func PrimaryDecorator

func PrimaryDecorator(node *model.Node, value reflect.Value) string

func PrimaryDecoratorFields

func PrimaryDecoratorFields(node *model.Node) []string

func Read

func Read(conn net.Conn) ([]byte, error)

Read data from socket

func ReadSize

func ReadSize(size int, conn net.Conn) ([]byte, error)

func TypeName

func TypeName(any interface{}) string

func TypeOf

func TypeOf(any interface{}) reflect.Type

func ValueAndType

func ValueAndType(any interface{}) (reflect.Value, reflect.Type)

func Write

func Write(data []byte, conn net.Conn) error

Write data to socket

Types

type DataStoreDecorator

type DataStoreDecorator interface {
	DataStoreTypeName() string
	Connect(...string) interface{}
	DoesNotExistError(error) bool
}

type DatatListener

type DatatListener interface {
	PortShutdown(port Port)
	HandleData([]byte, Port)
}

type IFetch

type IFetch interface {
}

type IHealthCeter

type IHealthCeter interface {
	AddPort(Port)
	ApplyReport(*model.Report)
	AddService(string, string)
	ServiceUuids(string) []string
	Clone() *model.HealthCenter
}
var HealthCenter IHealthCeter

type IIntrospect

type IIntrospect interface {
	Inspect(interface{}) (*model.Node, error)
	Node(string) (*model.Node, bool)
	NodeByType(p reflect.Type) (*model.Node, bool)
	NodeByTypeName(string) (*model.Node, bool)
	NodeByValue(interface{}) (*model.Node, bool)
	Nodes(bool, bool) []*model.Node
	Print()
	Registry() IRegistry
	Kind(*model.Node) reflect.Kind
	Clone(interface{}) interface{}
	AddDecorator(model.DecoratorType, interface{}, *model.Node)
	DecoratorOf(model.DecoratorType, *model.Node) interface{}
	TableView(string) (*model.TableView, bool)
	TableViews() []*model.TableView
}
var Introspect IIntrospect

type IORM

type IORM interface {
	Introspect() IIntrospect
	Persist(interface{}) error
	Fetch(IFetch) (interface{}, error)
}

type IOrmPlugin

type IOrmPlugin interface {
	Init(IORM, ...interface{}) error
	RelationalData() bool
	Decorator() DataStoreDecorator

	Persist(interface{}) error
	Fetch(fetch IFetch) (interface{}, error)
}

type IRegistry

type IRegistry interface {
	RegisterStruct(interface{}) bool
	RegisterStructType(reflect.Type) bool
	NewProtobufInstance(string) (proto.Message, error)
	NewInstance(string) (interface{}, error)
	TypeByName(string) (reflect.Type, error)
}
var Registry IRegistry

type IServiceCenter

type IServiceCenter interface {
}
var ServiceCenter IServiceCenter

type IServicePoints

type IServicePoints interface {
	RegisterServicePoint(proto.Message, ServicePointHandler, IRegistry) error
	Handle(proto.Message, model.Action, Port) (proto.Message, error)
}
var ServicePoints IServicePoints

type Port

type Port interface {
	Start()
	Addr() string
	Uuid() string
	Send([]byte) error
	Name() string
	Do(model.Action, string, proto.Message) error
	Shutdown()
	CreatedAt() int64
}

type ProtobufObjectType

type ProtobufObjectType interface {
	Add(interface{}) ([]byte, int)
	Get([]byte, int) (interface{}, int)
}

type ServicePointHandler

type ServicePointHandler interface {
	Post(proto.Message, Port) (proto.Message, error)
	Put(proto.Message, Port) (proto.Message, error)
	Patch(proto.Message, Port) (proto.Message, error)
	Delete(proto.Message, Port) (proto.Message, error)
	Get(proto.Message, Port) (proto.Message, error)
	EndPoint() string
}

Jump to

Keyboard shortcuts

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