common

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

cSpell:ignore gonic, orgs, sharded

cSpell:ignore bson, gonic, paulo ferreira, userro

cSpell:ignore bson, gonic, paulo ferreira, userro

cSpell:ignore dword, ferreira, otype, paulo, qword

cSpell:ignore gonic, orgs, paulo, ferreira

Index

Constants

View Source
const BYTE_BITS = 8
View Source
const DWORD_BITS = 32
View Source
const LOCAL_ID_BITS = 32 // NUMBER of BITS Used for LOCAL ID

LOCAL ID BIT MANAGEMENT

View Source
const LOCAL_ID_DWORD_OFFSET = 0 // BIT OFFSET in DWORD (uint32)
View Source
const LOCAL_ID_QWORD_OFFSET = 0 // BIT OFFSET in QWORD (uint64)
View Source
const LOCAL_QWORD_MASK = uint64(0x00000000FFFFFFFF) // LOWER DWORD
View Source
const OTYPE_ACTION = uint16(0x00FB) // ACTION Object
View Source
const OTYPE_BITS = 8 // OBJECT TYPE in GLOBAL ID

OBJECT TYPE BIT MANAGEMENT

View Source
const OTYPE_DWORD_MASK = uint32(0x00FF0000) // OBJECT TYPE BITS
View Source
const OTYPE_DWORD_OFFSET = 16 // BIT OFFSET in DWORD (uint32)
View Source
const OTYPE_INVITATION = uint16(0x00FE) // INVITATION Object
View Source
const OTYPE_KEY = uint16(0x00FD) // KEY Object
View Source
const OTYPE_NOTSET = uint16(0x0000) // Object Type NOT SET

KNOWN TYPES

View Source
const OTYPE_ORG = uint16(0x0002) // ORGANIZATION Object
View Source
const OTYPE_OTHER = uint16(0x00FF) // OTHER Object Type
View Source
const OTYPE_QWORD_OFFSET = OTYPE_DWORD_OFFSET + DWORD_BITS // BIT OFFSET in QWORD (uint64)
View Source
const OTYPE_REQUEST = uint16(0x00FC) // REQUEST Object
View Source
const OTYPE_STORE = uint16(0x0003) // STORE Object
View Source
const OTYPE_USER = uint16(0x0001) // USER Object
View Source
const OTYPE_WORD_OFFSET_MASK = uint16(0x00FF) // OBJECT TYPE for GLOBAL ID
View Source
const QWORD_BITS = 64

BITS for VARIOUS SIZES

View Source
const SHARD_GROUP_BITS = 4 // NUMBER of Bits Used for SHARD GROUP

SHARD GROUP BIT MANAGEMENT

View Source
const SHARD_GROUP_DWORD_MASK = uint32(0xF0000000) // ID for SHARD GROUP
View Source
const SHARD_GROUP_DWORD_OFFSET = DWORD_BITS - SHARD_GROUP_BITS // BIT OFFSET in DWORD (uint32)
View Source
const SHARD_GROUP_DWORD_OFFSET_MASK = uint32(0x0000000F) // ID for SHARD GROUP
View Source
const SHARD_GROUP_QWORD_OFFSET = SHARD_GROUP_DWORD_OFFSET + DWORD_BITS // BIT OFFSET in QWORD (uint64)
View Source
const SHARD_GROUP_WORD_OFFSET_MASK = uint16(0x000F) // ID for SHARD GROUP
View Source
const SHARD_ID_BITS = 12 // NUMBER of Bits Used for SHARD ID

SHARD ID BIT MANAGEMENT

View Source
const SHARD_ID_DWORD_MASK = uint32(0x00000FFF) // ID of SHARD in GROUP
View Source
const SHARD_ID_DWORD_OFFSET = 0 // BIT OFFSET in DWORD (uint32)
View Source
const SHARD_ID_QWORD_OFFSET = SHARD_GROUP_DWORD_OFFSET + DWORD_BITS // BIT OFFSET in QWORD (uint64)
View Source
const SHARD_QWORD_MASK = uint64(0xF0000FFF00000000) // UPPER DWORD

SEPARATION of PARTS

View Source
const SHARD_QWORD_OFFSET = 32 // BIT OFFSERR in QWORD
View Source
const SYSTEM_ADMINISTRATOR = uint64(0x1000000000000) // STAR System Administrator

GLOBAL OBJECT CONSTANTS

View Source
const SYSTEM_ORGANIZATION = uint64(0x2000000000000) // Global Management Organization
View Source
const WORD_BITS = 16

Variables

This section is empty.

Functions

func CodeToMessage

func CodeToMessage(code int) (int, string)

Convert a Code to a Message String

func ConfigProperty

func ConfigProperty(source map[string]interface{}, path string, dvalue interface{}) interface{}

func ConfigPropertyFloat64

func ConfigPropertyFloat64(source map[string]interface{}, path string, dvalue float64, nested error) (float64, error)

func ConfigPropertyINT

func ConfigPropertyINT(source map[string]interface{}, path string, dvalue int64, nested error) (int64, error)

func ConfigPropertyObject

func ConfigPropertyObject(source map[string]interface{}, path string, dvalue map[string]interface{}, nested error) (map[string]interface{}, error)

func ConfigPropertyString

func ConfigPropertyString(source map[string]interface{}, path string, dvalue string, nested error) (string, error)

func ConfigPropertyUINT

func ConfigPropertyUINT(source map[string]interface{}, path string, dvalue uint64, nested error) (uint64, error)

func IsObjectOfType

func IsObjectOfType(global uint64, t uint16) bool

func LocalIDFromID

func LocalIDFromID(global uint64) uint32

func ObjectTypeFromID

func ObjectTypeFromID(global uint64) uint16

func RandomGlobalID

func RandomGlobalID(group uint16, otype uint16, id uint32) uint64

func RandomShardID

func RandomShardID() uint32

func ShardFromID

func ShardFromID(global uint64) uint32

func ShardGlobalID

func ShardGlobalID(group uint16, otype uint16, shard uint32, id uint32) uint64

func ShardGroupFromID

func ShardGroupFromID(global uint64) uint16

func ShardInfoFromID

func ShardInfoFromID(global uint64) uint32

func StringEmptyOnNil

func StringEmptyOnNil(s *string) string

If nil String Pointer return Empty String (Allows Conversion Betwee String and String Pointer)

func StringNilOnEmpty

func StringNilOnEmpty(s string) *string

GLOBAL HELPERs // If Empty String return nil (Allows Conversion Betwee String and String Pointer)

func UTCTimeStamp

func UTCTimeStamp() string

UTCTimeStamp Return UTC Time Stamp String in RFC 3339

Types

type DBConnection

type DBConnection struct {
	Database string                 `json:"database"`
	User     string                 `json:"user,omitempty"`
	Password string                 `json:"password,omitempty"`
	Server   *Server                `json:"server"`
	Options  map[string]interface{} `json:"options,omitempty"`
}

DEFINITION: Database Connection

func (*DBConnection) FromConfig

func (s *DBConnection) FromConfig(base map[string]interface{}) error

type DBShard

type DBShard struct {
	Range        []uint32     `json:"range"`
	Connection   DBConnection `json:"connection"`
	DBConnection *sql.DB
}

DEFINITION: Database Shard

func (*DBShard) FromConfig

func (s *DBShard) FromConfig(base map[string]interface{}) error

type DBShardGroup

type DBShardGroup struct {
	Shards [](*DBShard) `json:"shards"`
}

DEFINITION: Database Shard Group

func (*DBShardGroup) FromConfig

func (s *DBShardGroup) FromConfig(base map[string]interface{}) error

type Server

type Server struct {
	Host string `json:"host,omitempty"`
	Port uint16 `json:"port,omitempty"`
}

A Server TCP/IP Connection Addres and Port

func (*Server) FromConfig

func (s *Server) FromConfig(base map[string]interface{}) error

type ShardedDatabase

type ShardedDatabase struct {
	Groups [](*DBShardGroup) `json:"shard-groups"`
}

DEFINITION: Sharded Database Definition

func (*ShardedDatabase) FromConfig

func (s *ShardedDatabase) FromConfig(base map[string]interface{}) error

type StoreSession

type StoreSession struct {
	// contains filtered or unexported fields
}

func ImportStoreSession

func ImportStoreSession(i string, valid_for uint16) (*StoreSession, error)

func NewStoreSession

func NewStoreSession(store uint64, key []byte, valid_for uint16) (*StoreSession, error)

func (*StoreSession) ExpireHex

func (o *StoreSession) ExpireHex() string

func (*StoreSession) ExpireTime

func (o *StoreSession) ExpireTime() *time.Time

func (*StoreSession) ExpireUnix

func (o *StoreSession) ExpireUnix() int64

func (*StoreSession) Export

func (o *StoreSession) Export() (string, error)

func (*StoreSession) Extend

func (o *StoreSession) Extend(d uint16) int64

func (*StoreSession) ExtendBy

func (o *StoreSession) ExtendBy() uint16

func (*StoreSession) Import

func (o *StoreSession) Import(v string) error

func (*StoreSession) IsExpired

func (o *StoreSession) IsExpired() bool

func (*StoreSession) IsValid

func (o *StoreSession) IsValid() bool

func (*StoreSession) Key

func (o *StoreSession) Key() []byte

func (*StoreSession) KeyHex

func (o *StoreSession) KeyHex() string

func (*StoreSession) SetExtendBy

func (o *StoreSession) SetExtendBy(by uint16) (uint16, error)

func (*StoreSession) Store

func (o *StoreSession) Store() uint64

func (*StoreSession) StoreHex

func (o *StoreSession) StoreHex() string

Jump to

Keyboard shortcuts

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