Documentation
¶
Index ¶
- Constants
- Variables
- func AcceptableIDType(id interface{}) (string, bool)
- func Adjust(ctx context.Context, obj interface{}, state map[string]interface{}) interface{}
- func ApplySpec(ctx context.Context, token, hostAddr string, specObj *model.SpecObject) error
- func ArrayContains(array []interface{}, value interface{}) bool
- func CheckParse(s string) (time.Time, error)
- func CloseTheCloser(c io.Closer)
- func CreateCorsObject() *cors.Cors
- func DeleteValue(ctx context.Context, key string, state map[string]interface{}) error
- func DownloadFileFromURL(url, dest string) error
- func Encrypt(aesKey []byte, value string) (string, error)
- func ExtractJoinInfoForInstantInvalidate(join []*model.JoinOption, joinKeysMapping map[string]map[string]string)
- func ExtractRequestParams(r *http.Request, reqParams model.RequestParams, body interface{}) model.RequestParams
- func GenerateJoinKeys(joinTable string, joinOn map[string]interface{}, ...)
- func GenerateJoinKeysForInstantInvalidate(joinTable string, joinOn map[string]interface{}, ...)
- func GetIDVariable(dbAlias string) string
- func GetTokenFromHeader(r *http.Request) string
- func HashString(stringValue string) string
- func IsValidJoin(on map[string]interface{}, jointTableName string) (bool, string)
- func JoinLeading(s1 string, s2 string, ch string) string
- func JoinLeadingTrailing(s1 string, s2 string, ch string) string
- func JoinTrailing(s1 string, s2 string, ch string) string
- func LoadBool(ctx context.Context, key interface{}, args map[string]interface{}) (bool, error)
- func LoadNumber(ctx context.Context, key interface{}, args map[string]interface{}) (float64, error)
- func LoadStringIfExists(value string, state map[string]interface{}) (string, error)
- func LoadValue(key string, state map[string]interface{}) (interface{}, error)
- func MakeHTTPRequest(ctx context.Context, request *HTTPRequest, vPtr interface{}) (int, error)
- func ParseGraphqlValue(value ast.Value, store M) (interface{}, error)
- func SingleLeading(s string, ch string) string
- func SingleLeadingTrailing(s string, ch string) string
- func SingleTrailing(s string, ch string) string
- func StoreValue(ctx context.Context, key string, value interface{}, ...) error
- func StoreValueInObject(key string, value interface{}, obj map[string]interface{}) error
- func StringExists(array []string, elements ...string) bool
- func Unzip(src string, dest string) error
- func UserHomeDir() string
- func Validate(dbType string, where map[string]interface{}, obj interface{}) bool
- type Array
- type Broker
- type DatabaseCollections
- type FileStoreType
- type GetSecrets
- type HTTPRequest
- type M
- type Object
- type OrchestratorType
- type RequestKind
- type TypeMakeHTTPRequest
Constants ¶
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" )
const ( // 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" )
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" )
const ( // PortHTTP is the port used for the http server PortHTTP string = "4122" // PortHTTPConnect is the port used for the http server with consul connect PortHTTPConnect string = "4124" // PortHTTPSecure is the port used for the http server with tls PortHTTPSecure string = "4126" )
const ( // GqlConnectionKeepAlive send every 20 second to client over websocket GqlConnectionKeepAlive string = "ka" // Server -> Client // GqlConnectionInit is used by graphql over websocket protocol GqlConnectionInit string = "connection_init" // Client -> Server // GqlConnectionAck is used by graphql over websocket protocol GqlConnectionAck string = "connection_ack" // Server -> Client // GqlConnectionError is used by graphql over websocket protocol GqlConnectionError string = "connection_error" // Server -> Client // GqlConnectionTerminate is used by graphql over websocket protocol GqlConnectionTerminate string = "connection_terminate" // Client -> Server // GqlStart is used by graphql over websocket protocol GqlStart string = "start" // Client -> Server // GqlData is used by graphql over websocket protocol GqlData string = "data" // Server -> Client // GqlError is used by graphql over websocket protocol GqlError string = "error" // Server -> Client // GqlComplete is used by graphql over websocket protocol GqlComplete string = "complete" // Server -> Client // GqlStop is used by graphql over websocket protocol GqlStop string = "stop" // Client -> Server )
const ( // EventDBCreate is fired for create request EventDBCreate string = "DB_INSERT" // EventDBUpdate is fired for update request EventDBUpdate string = "DB_UPDATE" // EventDBDelete is fired for delete request EventDBDelete string = "DB_DELETE" // EventFileCreate is fired for create request EventFileCreate string = "FILE_CREATE" // EventFileDelete is fired for delete request EventFileDelete string = "FILE_DELETE" )
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" // EventStatusFailed 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" )
const ( // TableEventingLogs is a variable for "event_logs" TableEventingLogs string = "event_logs" // TableInvocationLogs is a variable for "invocation_logs" TableInvocationLogs string = "invocation_logs" // SchemaInvocationLogs is a variable for invocaton schema SchemaInvocationLogs string = `` /* 267-byte string literal not displayed */ // SchemaEventLogs is a variable for event schema SchemaEventLogs string = `` /* 342-byte string literal not displayed */ )
const AdminSecretKID = "sc-admin-kid"
AdminSecretKID describes the kid to be used for admin secrets
const BuildVersion = "0.21.5"
BuildVersion is the current version of Space Cloud
const DLQEventTriggerPrefix = "dlq_"
DLQEventTriggerPrefix used as suffix for DLQ event trigger
const DefaultCacheTTLTimeout = 60 * 5
DefaultCacheTTLTimeout used for setting default ttl expiry if not specified the value is in seconds, current value corresponds to 5 minutes
const DefaultConfigFilePath string = "config.yaml"
DefaultConfigFilePath is the default path to load / store the config file
const DefaultContextTime = 100
DefaultContextTime used for creating default context time for endpoints
const GraphQLAggregate = "aggregate"
GraphQLAggregate is used by graphql aggregate clause
const GraphQLGroupByArgument = "group"
GraphQLGroupByArgument is used by graphql group clause
const InternalUserID string = "internal-sc-user"
InternalUserID is the auth.id used for internal requests
const MaxEventTokens int = 100
MaxEventTokens describes the maximum number of event workers
const SpaceCloudServiceName string = "space-cloud"
SpaceCloudServiceName is the service name space cloud will register itself with in service discovery mechanisms
Variables ¶
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
var ErrDatabaseDisabled = errors.New("Database is disabled. Please enable it")
ErrDatabaseDisabled is thrown when an operation is requested on a disabled database
var ErrInvalidParams = errors.New("Invalid parameter provided")
ErrInvalidParams is thrown when the input parameters for an operation are invalid
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 ¶
AcceptableIDType converts a provied id to string
func ArrayContains ¶
func ArrayContains(array []interface{}, value interface{}) bool
ArrayContains checks if the array contains the value provided
func CheckParse ¶
CheckParse checks if the string can be parsed or not
func CreateCorsObject ¶
CreateCorsObject creates a cors object with the required config
func DeleteValue ¶
DeleteValue -- deletes a value in the provided state
func DownloadFileFromURL ¶
DownloadFileFromURL downloads a file from url and stores it at a given destination
func ExtractJoinInfoForInstantInvalidate ¶
func ExtractJoinInfoForInstantInvalidate(join []*model.JoinOption, joinKeysMapping map[string]map[string]string)
ExtractJoinInfoForInstantInvalidate extracts join info
func ExtractRequestParams ¶
func ExtractRequestParams(r *http.Request, reqParams model.RequestParams, body interface{}) model.RequestParams
ExtractRequestParams extract request info from http request & stores it in reqParam variable
func GenerateJoinKeys ¶
func GenerateJoinKeys(joinTable string, joinOn map[string]interface{}, databaseRow map[string]interface{}, joinKeysMapping map[string]map[string]string)
GenerateJoinKeys generates join keys
func GenerateJoinKeysForInstantInvalidate ¶
func GenerateJoinKeysForInstantInvalidate(joinTable string, joinOn map[string]interface{}, joinKeysMapping map[string]map[string]string)
GenerateJoinKeysForInstantInvalidate generates join keys
func GetIDVariable ¶
GetIDVariable gets the id variable for the provided db type
func GetTokenFromHeader ¶
GetTokenFromHeader returns the token from the request header
func HashString ¶
HashString hashes a string value and base64 encodes the result
func IsValidJoin ¶
IsValidJoin checks if join is valid
func JoinLeading ¶
JoinLeading joins s1 and s2, using ch, and ensures ch occurs at the start
func JoinLeadingTrailing ¶
JoinLeadingTrailing joins s1 and s2, using ch, and ensures ch occurs at the start and end
func JoinTrailing ¶
JoinTrailing joins s1 and s2, using ch, and ensures ch occurs at the end
func LoadNumber ¶
LoadNumber loads a key as a float. Throws error
func LoadStringIfExists ¶
LoadStringIfExists loads a value if its present else returns the same
func MakeHTTPRequest ¶
func MakeHTTPRequest(ctx context.Context, request *HTTPRequest, vPtr interface{}) (int, error)
MakeHTTPRequest fires an http request and returns a response
func ParseGraphqlValue ¶
ParseGraphqlValue returns an interface that can be casted to string
func SingleLeading ¶
SingleLeading ensures that a string s starts with ch, but doesnt end with it
func SingleLeadingTrailing ¶
SingleLeadingTrailing ensures that a string s starts and ends with single occurence of ch
func SingleTrailing ¶
SingleTrailing ensures that a string s ends with ch, but doesnt start with it
func StoreValue ¶
func StoreValue(ctx context.Context, key string, value interface{}, state map[string]interface{}) error
StoreValue -- stores a value in the provided state
func StoreValueInObject ¶
StoreValueInObject -- stores a value in provided object
func StringExists ¶
StringExists returns true if the given string exists in the array
Types ¶
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
Array is an atomic array
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 DatabaseCollections ¶
type DatabaseCollections struct {
TableName string `db:"table_name" json:"tableName"`
}
DatabaseCollections stores all callections of sql or postgres or mongo
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 GetSecrets ¶
GetSecrets gets fileStore and database secrets from runner
type HTTPRequest ¶
type HTTPRequest struct { Headers headers Method, URL string Token, SCToken string Params io.Reader }
HTTPRequest describes the request object
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object is an atomic array
type OrchestratorType ¶
type OrchestratorType string
OrchestratorType is the type of the orchestrator
const ( // Kubernetes is the type used for a kubernetes deployement Kubernetes OrchestratorType = "kubernetes" )
type RequestKind ¶
type RequestKind string
RequestKind specifies the kind of the request
const ( // RequestKindDirect is used when an http request is to be made directly RequestKindDirect RequestKind = "direct" // RequestKindConsulConnect is used when an http request is to be made via consul connect RequestKindConsulConnect RequestKind = "consul-connect" )