tools

package module
v0.5.22 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: GPL-3.0 Imports: 10 Imported by: 7

Documentation

Index

Constants

View Source
const (
	ACCESSRead     = 1
	ACCESSInser    = 2
	ACCESSUpdate   = 4
	ACCESSDelete   = 8
	ACCESSFullRW   = 15
	ACCESSDesigner = 32
	ACCESSOwner    = 128
)

Access level contants

View Source
const (
	ErrOK           uint16 = 0
	ErrNotFound     uint16 = 1
	ErrExist        uint16 = 2
	ErrAccessDenied uint16 = 3
	ErrTimeOut      uint16 = 4
	ErrInvalidParam uint16 = 5

	// error above 100 are server side error
	// and are hidden from the client
	ErrInternal uint16 = 32767
)

User Error Access level contants

View Source
const (
	TypSrvDOCKER        uint8 = 1
	TypSrvKUBERNETES    uint8 = 2
	TypSrvISTIO         uint8 = 3
	TypSrvSIMPLEPROCESS uint8 = 4
)

Type Server

View Source
const (
	TraceFatalError      uint64 = 0
	TraceSystemError     uint64 = 1
	TraceUserError       uint64 = 2
	TraceWarning         uint64 = 4
	TraceFunctionCalls   uint64 = 8
	TraceDenyAccess      uint64 = 16
	TraceAllowClientInfo uint64 = 32

	// Service Specific
	TraceAll uint64 = 9223372036854775807
)

Tools Trace contants

View Source
const (
	SVCUnknown uint32 = 0
	SVCEcho    uint32 = 1
	SVCEntry   uint32 = 2
	SVCLogin   uint32 = 3
	SVCDbAPI   uint32 = 4
	SVCNotif   uint32 = 5
)

ServiceID ...

Variables

View Source
var APIDefinitions = map[API]APIDef{
	APIUnknown:             APIDef{"???", SVCUnknown},
	APIHealth:              APIDef{"Health", SVCUnknown},
	APILOGINLOGIN:          APIDef{"Login", SVCLogin},
	APILOGINLOGOUT:         APIDef{"Logout", SVCLogin},
	API4:                   APIDef{"Api4", SVCUnknown},
	API5:                   APIDef{"Api5", SVCUnknown},
	API6:                   APIDef{"Api6", SVCUnknown},
	APITestOK:              APIDef{"Test_OK", SVCUnknown},
	APITestError:           APIDef{"TestErrorVisible", SVCUnknown},
	APITestErrorNonVisible: APIDef{"TestErrorNonVisible", SVCUnknown},
	APITokenRequired:       APIDef{"ReservedAPI", SVCUnknown},
	APITestPanic:           APIDef{"Test_Panic", SVCUnknown},
	APIDB_BEGIN:            ApiDef{"Begin", SVCDbAPI},
	APIDB_COMMIT:           ApiDef{"Begin", SVCDbAPI},
	APIDB_ROLLBACK:         ApiDef{"Begin", SVCDbAPI},
	APIDB_QUERY:            ApiDef{"Begin", SVCDbAPI},
	APIMax:                 APIDef{"InternalMaxApi", SVCUnknown},
}

APIDefinitions ...

View Source
var FLLockTimeOut = 5 * time.Second

LockTimeOut

View Source
var SvcDefinition = []ServiceDef{
	{Server: "", ServiceID: SVCUnknown, ServiceName: "", Instance: "", Port: "", URL: ""},
	{Server: "localhost", ServiceID: SVCEcho, ServiceName: "echo", Instance: "", Port: "1234", URL: ""},
	{Server: "localhost", ServiceID: SVCEntry, ServiceName: "api", Instance: "prod", Port: "5001", URL: ""},
	{Server: "localhost", ServiceID: SVCEntry, ServiceName: "api", Instance: "test", Port: "4001", URL: ""},
	{Server: "localhost", ServiceID: SVCLogin, ServiceName: "login", Instance: "prod", Port: "5002", URL: ""},
	{Server: "localhost", ServiceID: SVCLogin, ServiceName: "login", Instance: "test", Port: "4002", URL: ""},
	{Server: "localhost", ServiceID: SVCDbAPI, ServiceName: "dbapi", Instance: "prod", Port: "5003", URL: ""},
	{Server: "localhost", ServiceID: SVCDbAPI, ServiceName: "dbapi", Instance: "test", Port: "4003", URL: ""},
	{Server: "localhost", ServiceID: SVCNotif, ServiceName: "svcnotification", Instance: "prod", Port: "5004", URL: ""},
	{Server: "localhost", ServiceID: SVCNotif, ServiceName: "svcnotification", Instance: "test", Port: "4004", URL: ""},
}

SvcDefinition linked to the const def

View Source
var TypSrvString = map[string]uint8{
	"DOCKER":     TypSrvDOCKER,
	"KUBERNETES": TypSrvKUBERNETES,
	"ISTIO":      TypSrvISTIO,
	"PROCESS":    TypSrvSIMPLEPROCESS,
}

TypSrvString decoding TypSrv

Functions

func CanAccess

func CanAccess(ctx *pb.ContextData, requiredAccess uint32, info string) bool

CanAccess ...

func CreateNewContext added in v0.4.43

func CreateNewContext(dbName string) *pb.ContextData

CreateNewContext ..

func CreateNewLinkedContext added in v0.5.8

func CreateNewLinkedContext(c *pb.ContextData, dbName string) *pb.ContextData

CreateNewLinkedContext ..

func CtxLog added in v0.5.8

func CtxLog(c *pb.ContextData, functionName string, message string, arg ...interface{})

CtxLog a message in the DTrace context

func CtxTrace added in v0.5.8

func CtxTrace(c *pb.ContextData, functionName string, level uint64, message string, arg ...interface{})

CtxTrace a message in the DTrace context

func GetAPIString

func GetAPIString(a API) string

GetAPIString ...

func GetEnv added in v0.5.3

func GetEnv(key, fallback string, opt ...bool) string

GetEnv ..

func GetInstance added in v0.5.3

func GetInstance() string

GetInstance ...

func GetMilliseconds added in v0.4.47

func GetMilliseconds(oldVal int64) int64

GetMilliseconds ..

func GetSecret added in v0.5.22

func GetSecret(secretName string) interface{}

func GetServiceString

func GetServiceString(svcID uint32) string

GetServiceString ...

func GetStringFromError added in v0.4.21

func GetStringFromError(code codes.Code) string

GetStringFromError ..

func IsCtxTraced added in v0.5.22

func IsCtxTraced(c *pb.ContextData, traceLevel uint64) bool

func IsDesigner

func IsDesigner(ctx *pb.ContextData, info string) bool

IsDesigner ...

func IsErrorVisible added in v0.4.21

func IsErrorVisible(code codes.Code) bool

IsErrorVisible ...

func IsOwner

func IsOwner(ctx *pb.ContextData, info string) bool

IsOwner ...

func IsSvcMaskSet

func IsSvcMaskSet(svcMask uint64, sidToCheck uint8) bool

IsSvcMaskSet ..

func MakeSystemError added in v0.5.8

func MakeSystemError(c *pb.ContextData, functionName string, err error, message string, arg ...interface{}) error

MakeSystemError a message in the DTrace context

func MakeSystemErrorAndPanic added in v0.5.8

func MakeSystemErrorAndPanic(c *pb.ContextData, functionName string, err error, message string, arg ...interface{})

MakeSystemErrorAndPanic a message in the DTrace context

func MakeUserError added in v0.5.8

func MakeUserError(c *pb.ContextData, functionName string, errNo uint16, level uint64, message string, arg ...interface{}) error

MakeUserError a message in the DTrace context

func NowAsUnixMilliseconds added in v0.4.21

func NowAsUnixMilliseconds() int64

NowAsUnixMilliseconds ..

func Ping

func Ping() bool

Ping ...

func ServiceFromString

func ServiceFromString(strSvc string) uint32

ServiceFromString ...

func WaitTimeout added in v0.4.21

func WaitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool

WaitTimeout ...

func WriteLog

func WriteLog(ctx *pb.ContextData, locationPath string, format string, arg ...interface{})

WriteLog ..

func WriteTrace

func WriteTrace(ctx *pb.ContextData, location string, message string)

WriteTrace ...

Types

type API

type API uint8

API Our internal API type, and const

const (
	APIUnknown             API = 0
	APIHealth              API = 1
	APILOGINLOGIN          API = 2
	APILOGINLOGOUT         API = 3
	API4                   API = 4
	API5                   API = 5
	API6                   API = 6
	APITestOK              API = 7
	APITestError           API = 8
	APITestErrorNonVisible API = 9
	APITokenRequired       API = 10
	APITestPanic           API = 11
	APIDB_BEGIN            API = 12
	APIDB_COMMIT           API = 13
	APIDB_ROLLBACK         API = 14
	APIDB_QUERY            API = 15
	APIMax                 API = 16
)

List of known APIs

func GetAPIFromString

func GetAPIFromString(apiStr string) API

GetAPIFromString ...

type APIDef

type APIDef struct {
	ServiceID uint32
	// contains filtered or unexported fields
}

APIDef ...

type ByteField added in v0.4.48

type ByteField []byte

ByteField []byte Fields

type ByteFields added in v0.4.48

type ByteFields []ByteField

ByteFields []ByteField

type IDBStats added in v0.4.50

type IDBStats struct {
	MaxOpenConnections int // Maximum number of open connections to the database; added in Go 1.11
	// Pool Status
	OpenConnections int // The number of established connections both in use and idle.
	InUse           int // The number of connections currently in use; added in Go 1.11
	Idle            int // The number of idle connections; added in Go 1.11

	// Counters
	WaitCount         int64         // The total number of connections waited for; added in Go 1.11
	WaitDuration      time.Duration // The total time blocked waiting for a new connection; added in Go 1.11
	MaxIdleClosed     int64         // The total number of connections closed due to SetMaxIdleConns; added in Go 1.11
	MaxLifetimeClosed int64         // The
}

IDBStats ...

type JByteDocument added in v0.4.49

type JByteDocument struct {
	ID uint64    `json:"id"`
	J  ByteField `json:"j"`
}

JByteDocument ...

type JDbDocumentMap added in v0.5.10

type JDbDocumentMap struct {
	ID uint64 `json:"id"`
	J  JField `json:"j"`
}

JDbDocumentMap struct to get our data id: uint64 json data, can be full/partial documents (projection)

func ConvertBytesDocToMap added in v0.5.10

func ConvertBytesDocToMap(docBytes *pb.DbDocumentBytes) (JDbDocumentMap, error)

ConvertBytesDocToMap ...

type JField added in v0.4.43

type JField map[string]interface{}

JField Json field

func (JField) Value added in v0.4.48

func (a JField) Value() []byte

Value return an array of bytes called by the postgres driver for JField fields

type JFields added in v0.4.48

type JFields []JField

JFields array JField (insert)

type ServiceDef

type ServiceDef struct {
	Server      string // Server, usually localhost
	ServiceID   uint32 // ServiceID, only value used by apps
	ServiceName string // ServiceName for kubernetes, or printf
	Instance    string // Instance. In Kubernetes need to be the same
	Port        string // port number
	URL         string // Self generated, url to use
	// contains filtered or unexported fields
}

ServiceDef define the service

func GetServiceDefinition

func GetServiceDefinition(sid uint32, instance ...string) ServiceDef

GetServiceDefinition ...

func GetServiceDefinitionByName added in v0.4.47

func GetServiceDefinitionByName(serviceName string, instance ...string) ServiceDef

GetServiceDefinitionByName ..

func (*ServiceDef) GetPort

func (s *ServiceDef) GetPort() string

GetPort ...

func (*ServiceDef) GetURL

func (s *ServiceDef) GetURL() string

GetURL returns the url to connect to the serviceDef Dynamically regenerated

Directories

Path Synopsis
proto module

Jump to

Keyboard shortcuts

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