utils

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2019 License: Apache-2.0 Imports: 15 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// One operation returns a single document from the database
	One string = "one"

	// All operation returns multiple documents from the database
	All string = "all"

	// Count operation returns the number of documents which match the condition
	Count string = "count"

	// Distinct operation returns distinct values
	Distinct string = "distinct"

	// Upsert creates a new document if it doesn't exist, else it updates exiting document
	Upsert string = "upsert"
)
View Source
const (
	// RealtimeWorkerCount are the number of goroutines to process realtime data
	RealtimeWorkerCount int = 10

	// FunctionsWorkerCount are the number of goroutines to process functions data
	FunctionsWorkerCount int = 10

	// RealtimeInsert is for create operations
	RealtimeInsert string = "insert"

	// RealtimeUpdate is for update operations
	RealtimeUpdate string = "update"

	// RealtimeDelete is for delete operations
	RealtimeDelete string = "delete"

	// RealtimeInitial is for the initial data
	RealtimeInitial string = "initial"
)
View Source
const (
	// TypeRealtimeSubscribe is the request type for live query subscription
	TypeRealtimeSubscribe string = "realtime-subscribe"

	// TypeRealtimeUnsubscribe is the request type for live query subscription
	TypeRealtimeUnsubscribe string = "realtime-unsubscribe"

	// TypeRealtimeFeed is the response type for realtime feed
	TypeRealtimeFeed string = "realtime-feed"

	// TypeServiceRegister is the request type for service registration
	TypeServiceRegister string = "service-register"

	// TypeServiceUnregister is the request type for service removal
	TypeServiceUnregister string = "service-unregister"

	// TypeServiceRequest is type triggering a service's function
	TypeServiceRequest string = "service-request"

	// TypePubsubSubscribe is type triggering a pubsub subscribe
	TypePubsubSubscribe string = "pubsub-subscribe"

	// TypePubsubSubscribeFeed is type having a pubsub subscribe feed
	TypePubsubSubscribeFeed string = "pubsub-subscribe-feed"

	// TypePubsubUnsubscribe is type triggering a pubsub unsubscribe
	TypePubsubUnsubscribe string = "pubsub-unsubscribe"

	// TypePubsubUnsubscribeAll is type triggering a pubsub unsubscribe all
	TypePubsubUnsubscribeAll string = "pubsub-unsubscribe-all"
)
View Source
const (
	// PortHTTP is the port used for the http server
	PortHTTP string = "4122"

	// PortGRPC is the port used for the grpc server
	PortGRPC string = "4124"

	// PortHTTPSecure is the port used for the http server with tls
	PortHTTPSecure string = "4126"

	// PortGRPCSecure is the port used for the grpc server with tls
	PortGRPCSecure string = "4128"

	// PortNatsServer is the port used for nats
	PortNatsServer int = 4222

	// PortNatsCluster is the port used by nats for clustering
	PortNatsCluster int = 4248

	// PortGossip is used for the membership protocol
	PortGossip string = "4232"

	// PortRaft is used internally by raft
	PortRaft string = "4234"
)
View Source
const (
	// GQL_CONNECTION_KEEP_ALIVE send every 20 second to client over websocket
	GQL_CONNECTION_KEEP_ALIVE string = "ka" // Server -> Client
	// GQL_CONNECTION_INIT is used by graphql over websocket protocol
	GQL_CONNECTION_INIT string = "connection_init" // Client -> Server
	// GQL_CONNECTION_ACK is used by graphql over websocket protocol
	GQL_CONNECTION_ACK string = "connection_ack" // Server -> Client
	// GQL_CONNECTION_ERROR is used by graphql over websocket protocol
	GQL_CONNECTION_ERROR string = "connection_error" // Server -> Client
	// GQL_CONNECTION_TERMINATE is used by graphql over websocket protocol
	GQL_CONNECTION_TERMINATE string = "connection_terminate" // Client -> Server
	// GQL_START is used by graphql over websocket protocol
	GQL_START string = "start" // Client -> Server
	// GQL_DATA is used by graphql over websocket protocol
	GQL_DATA string = "data" // Server -> Client
	// GQL_ERROR is used by graphql over websocket protocol
	GQL_ERROR string = "error" // Server -> Client
	// GQL_COMPLETE is used by graphql over websocket protocol
	GQL_COMPLETE string = "complete" // Server -> Client
	// GQL_STOP is used by graphql over websocket protocol
	GQL_STOP string = "stop" // Client -> Server
)
View Source
const (
	// EventCreate is fired for create request
	EventCreate string = "create-crud"

	// EventUpdate is fired for update request
	EventUpdate string = "update-crud"

	// EventDelete is fired for delete request
	EventDelete string = "delete-crud"
)
View Source
const (
	// EventStatusIntent signifies that the event hasn't been staged yet
	EventStatusIntent string = "intent"

	// EventStatusStaged signifies that the event can be processed
	EventStatusStaged string = "staged"

	// EventStatusProcessed signifies that the event has been successfully been processed and can be deleted
	EventStatusProcessed string = "processed"

	// EventStatusCancelled signifies that the event has failed and should not be processed
	EventStatusFailed string = "failed"

	// EventStatusCancelled signifies that the event has been cancelled and should not be processed
	EventStatusCancelled string = "cancel"
)
View Source
const BuildVersion = "0.12.1"

BuildVersion is the current version of Space Cloud

View Source
const DefaultConfigFilePath string = "config.yaml"

DefaultConfigFilePath is the default path to load / store the config file

View Source
const InternalUserID string = "internal-sc-user"

InternalUserID is the auth.id used for internal requests

View Source
const MaxEventTokens int = 100

MaxEventTokens describes the maximum number of event workers

View Source
const (
	// PayloadSize is the size of the payload(in bytes) in file upload and download
	PayloadSize int = 256 * 1024 // 256 kB
)
View Source
const RaftSnapshotDirectory string = "raft-store"

RaftSnapshotDirectory is where the snapshot of the log is stored

View Source
const (
	// ScopeDeploy is te scope used for the deploy module
	ScopeDeploy string = "deploy"
)
View Source
const TypeRegisterRequest string = "register"

TypeRegisterRequest is the space cloud register request

Variables

View Source
var ErrDatabaseConfigAbsent = errors.New("No such database found in SC config file")

ErrDatabaseConfigAbsent is thrown when database config is not present

View Source
var ErrDatabaseConnection = errors.New("Could not connect to database. Make sure it is up and connection string provided to SC is correct")

ErrDatabaseConnection is thrown when SC was unable to connect to the requested database

View Source
var ErrDatabaseDisabled = errors.New("Database is disabled. Please enable it")

ErrDatabaseDisabled is thrown when an operation is requested on a disabled database

View Source
var ErrInvalidParams = errors.New("Invalid parameter provided")

ErrInvalidParams is thrown when the input parameters for an operation are invalid

View Source
var ErrUnsupportedDatabase = errors.New("Unsupported database. Make sure your database type is correct")

ErrUnsupportedDatabase is thrown when an invalid db type is provided

Functions

func AcceptableIDType added in v0.12.0

func AcceptableIDType(id interface{}) (string, bool)

AcceptableIDType converts a provied id to string

func Adjust

func Adjust(obj interface{}, state map[string]interface{}) interface{}

Adjust loads value from state if referenced

func DownloadFileFromURL added in v0.10.0

func DownloadFileFromURL(url, dest string) error

DownloadFileFromURL downloads a file from url and stores it at a given destination

func GetIDVariable added in v0.12.0

func GetIDVariable(dbType string) string

GetIDVariable gets the id variable for the provided db type

func JoinLeading added in v0.12.0

func JoinLeading(s1 string, s2 string, ch string) string

JoinLeading joins s1 and s2, using ch, and ensures ch occurs at the start

func JoinLeadingTrailing added in v0.12.0

func JoinLeadingTrailing(s1 string, s2 string, ch string) string

JoinLeadingTrailing joins s1 and s2, using ch, and ensures ch occurs at the start and end

func JoinTrailing added in v0.12.0

func JoinTrailing(s1 string, s2 string, ch string) string

JoinTrailing joins s1 and s2, using ch, and ensures ch occurs at the end

func LoadBool

func LoadBool(key interface{}, args map[string]interface{}) (bool, error)

LoadBool loads a key as a float. Throws error

func LoadNumber

func LoadNumber(key interface{}, args map[string]interface{}) (float64, error)

LoadNumber loads a key as a float. Throws error

func LoadStringIfExists

func LoadStringIfExists(value string, state map[string]interface{}) string

LoadStringIfExists loads a value if its present else returns the same

func LoadValue

func LoadValue(key string, state map[string]interface{}) (interface{}, error)

LoadValue loads a value from the state

func ParseGraphqlValue added in v0.12.0

func ParseGraphqlValue(value ast.Value, store M) (interface{}, error)

ParseGraphqlValue returns an interface that can be casted to string

func SingleLeading added in v0.12.0

func SingleLeading(s string, ch string) string

SingleLeading ensures that a string s starts with ch, but doesnt end with it

func SingleLeadingTrailing added in v0.12.0

func SingleLeadingTrailing(s string, ch string) string

SingleLeadingTrailing ensures that a string s starts and ends with single occurence of ch

func SingleTrailing added in v0.12.0

func SingleTrailing(s string, ch string) string

SingleTrailing ensures that a string s ends with ch, but doesnt start with it

func Unzip added in v0.10.0

func Unzip(src string, dest string) error

Unzip unzips a source file to a given destination

func UserHomeDir added in v0.10.0

func UserHomeDir() string

UserHomeDir returns the path of home directory of user

func Validate added in v0.12.0

func Validate(where map[string]interface{}, obj interface{}) bool

Validate checks if the provided document matches with the where clause

Types

type Array added in v0.12.0

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

Array is an atomic array

func NewArray added in v0.12.0

func NewArray(length int) *Array

NewArray creates a new array

func (*Array) GetAll added in v0.12.0

func (a *Array) GetAll() []interface{}

GetAll gets the array

func (*Array) Set added in v0.12.0

func (a *Array) Set(index int, value interface{})

Set sets an item in the array at a particular index

type Broker

type Broker string

Broker is the type of broker used by Space Cloud

const (
	// Nats is the type used for Nats
	Nats Broker = "nats"
)

type DBType

type DBType string

DBType is the type of database used for a particular crud operation

const (
	// Mongo is the type used for MongoDB
	Mongo DBType = "mongo"

	// MySQL is the type used for MySQL
	MySQL DBType = "sql-mysql"

	// Postgres is the type used for PostgresQL
	Postgres DBType = "sql-postgres"
)

type DatabaseCollections added in v0.12.0

type DatabaseCollections struct {
	TableName string `db:"table_name" json:"tableName"`
}

DatabaseCollections stores all callections of sql or postgres or mongo

type FieldType added in v0.12.0

type FieldType struct {
	FieldName    string  `db:"Field"`
	FieldType    string  `db:"Type"`
	FieldNull    string  `db:"Null"`
	FieldKey     string  `db:"Key"`
	FieldDefault *string `db:"Default"`
	FieldExtra   string  `db:"Extra"`
}

FieldType is the type for storing sql inspection information

type FileOpType

type FileOpType string

FileOpType is the type of file operation being performed on the file store

const (
	// FileRead is the type used for read operations
	FileRead FileOpType = "read"

	// FileCreate is the type used for create operations
	FileCreate FileOpType = "create"

	// FileDelete is the type used for delete operations
	FileDelete FileOpType = "delete"
)

type FileStoreType

type FileStoreType string

FileStoreType is the type of file store used

const (
	// Local is the type used for the local filesystem
	Local FileStoreType = "local"

	// AmazonS3 is the type used for the AmazonS3 storage
	AmazonS3 FileStoreType = "amazon-s3"

	// GCPStorage is the type used for the GCP storage
	GCPStorage FileStoreType = "gcp-storage"
)

type ForeignKeysType added in v0.12.0

type ForeignKeysType struct {
	TableName      string `db:"TABLE_NAME"`
	ColumnName     string `db:"COLUMN_NAME"`
	ConstraintName string `db:"CONSTRAINT_NAME"`
	RefTableName   string `db:"REFERENCED_TABLE_NAME"`
	RefColumnName  string `db:"REFERENCED_COLUMN_NAME"`
}

ForeignKeysType is the type for storing foreignkeys information of sql inspection

type M added in v0.12.0

type M map[string]interface{}

M is a type for map

type Object added in v0.12.0

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

Object is an atomic array

func NewObject added in v0.12.0

func NewObject() *Object

NewObject creates a new atomic object

func (*Object) Get added in v0.12.0

func (obj *Object) Get(key string) (value interface{}, present bool)

Get gets the value of a key from the object

func (*Object) GetAll added in v0.12.0

func (obj *Object) GetAll() map[string]interface{}

GetAll returns the entire object

func (*Object) Set added in v0.12.0

func (obj *Object) Set(key string, value interface{})

Set sets a key in the object with a value

type OperationType

type OperationType string

OperationType is the type of operation being performed on the database

const (
	// Create is the type used for insert operations
	Create OperationType = "create"

	// Read is the type used for query operation
	Read OperationType = "read"

	// Update is the type used ofr update operations
	Update OperationType = "update"

	// Delete is the type used for delete operations
	Delete OperationType = "delete"

	// Aggregation is the type used for aggregations
	Aggregation OperationType = "aggr"
)

type OrchestratorType added in v0.10.0

type OrchestratorType string

OrchestratorType is the type of the orchestrator

const (
	// Kubernetes is the type used for a kubernetes deployement
	Kubernetes OrchestratorType = "kubernetes"
)

type PubsubType added in v0.12.0

type PubsubType string

PubsubType is the type of pubsub request

const (
	// Publish is the type used for publish requests
	Publish PubsubType = "publish"

	// Subscribe is the type used for subscribe requests
	Subscribe PubsubType = "subscribe"
)

type RaftCommandType added in v0.10.0

type RaftCommandType string

RaftCommandType is the type received in the raft commands

const (
	// RaftCommandSet is used to set a projects config
	RaftCommandSet RaftCommandType = "set"

	// RaftCommandSetDeploy is used to set the deploy config
	RaftCommandSetDeploy RaftCommandType = "set-deploy"

	// RaftCommandSetOperation is used to set the deploy config
	RaftCommandSetOperation RaftCommandType = "set-operation"

	// RaftCommandSetStatic is used to set the deploy config
	RaftCommandSetStatic RaftCommandType = "set-static"

	// RaftCommandAddInternalRouteOperation is used to add internal routes
	RaftCommandAddInternalRouteOperation RaftCommandType = "add-internal-route"

	// RaftCommandAddInternalEventOperation is used to add internal routes
	RaftCommandAddInternalEventOperation RaftCommandType = "add-internal-event"

	// RaftCommandRemoveInternalEventOperation is used to add internal routes
	RaftCommandRemoveInternalEventOperation RaftCommandType = "remove-internal-event"

	// RaftCommandDelete is used to delete a projects config
	RaftCommandDelete RaftCommandType = "delete"
)

type RealTimeProtocol

type RealTimeProtocol string

RealTimeProtocol is the type of protocol requested for realtime.

const (
	// Websocket for realtime implementation.
	Websocket RealTimeProtocol = "Websocket"

	// GRPC for realtime implementation.
	GRPC RealTimeProtocol = "GRPC"

	// GRPCService for Service implementation.
	GRPCService RealTimeProtocol = "GRPC-Service"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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