Documentation ¶
Index ¶
- Constants
- Variables
- func AppLocationInQuery(params map[string][]string) bool
- func GetDeploymentConfig(data []byte) (newDepcfg DepCfg, bindings []Bindings, err error)
- func GetLogDirectoryAndFileName(funcDetails *FunctionDetails, eventingDir string) (dirName, fileName string)
- func NamespaceInQuery(params map[string][]string) bool
- func PossibleStateChange(currState string, event AppState) (map[string]struct{}, error)
- func QueryMap(appLocation AppLocation) map[string][]string
- func QueryMapNamesapce(namespace Namespace) map[string][]string
- func ValidateSettings(settings map[string]interface{}) (err error)
- type AppLocation
- type AppState
- func (as AppState) Clone() (clone AppState)
- func (e AppState) Equals(e2 AppState) bool
- func (e AppState) GetLifeCycle() LifeCycleOp
- func (a AppState) String() string
- func (as *AppState) UnmarshalJSON(b []byte) error
- func (appState *AppState) VerifyAndMergeAppState(appStateMap map[string]interface{}) (bool, error)
- type AppVersion
- type Application
- type Bindings
- type BucketBinding
- type ConstantBinding
- type CurlBinding
- type DepCfg
- type FunctionDetails
- func (fd *FunctionDetails) Clone(redact bool) *FunctionDetails
- func (fd *FunctionDetails) GetAppBytes(v AppVersion) (json.Marshaler, error)
- func (fd *FunctionDetails) GetDestinationKeyspace(srcCheck bool) (dsts map[Keyspace]Writer, err error)
- func (fd *FunctionDetails) GetRequestType() requestType
- func (fd *FunctionDetails) GetSourceAndDestinations(srcCheck bool) (src Keyspace, dsts map[Keyspace]Writer, err error)
- func (fd *FunctionDetails) GetStorageBytes(sc StorageConfig) StorageBytes
- func (fd *FunctionDetails) IsSourceMutationPossible() bool
- func (fd *FunctionDetails) ModifyAppCode(modify bool) string
- func (f FunctionDetails) String() string
- func (nFuncDetails *FunctionDetails) ValidateBinding(possibleChanges map[string]struct{}, oldBindings []Bindings) (changed bool, err error)
- func (fd *FunctionDetails) VerifyAndMergeDepCfg(allowedFields map[string]struct{}, newDepcfg DepCfg, bindings []Bindings) (bool, error)
- func (fd *FunctionDetails) VerifyAndMergeSettings(allowedFields map[string]struct{}, settings map[string]interface{}) (changed bool, err error)
- type HandlerSettings
- type InitSettings
- type Keyspace
- type KeyspaceInfo
- type LanguageRuntimeSettings
- type LifeCycleOp
- type LogLevel
- type MetaInfo
- type Namespace
- type OldApplication
- type OldNamespace
- type Owner
- type State
- type StorageBytes
- type StorageConfig
- type Writer
Constants ¶
const ( GlobalValue = "*" DefaultScopeOrCollection = "_default" )
const ( MetaKvStore source = iota RestApi )
const ( RequestNone requestType = iota RequestBucket RequestScope RequestCollection )
const ( NoConsistency = n1qlConsistency("") None = n1qlConsistency("none") Request = n1qlConsistency("request") )
const ( Everyting = streamBoundary("everyting") FromNow = streamBoundary("from_now") FromPrior = streamBoundary("from_prior") )
const ( Bucket bindingType = iota Curl Constant )
const (
PASSWORD_MASK = "*****"
)
Variables ¶
var ( ErrInvalidState = errors.New("invalid state provided") ErrStateTransNotPossible = errors.New("state transition not possible") )
var ( NoAuth = authType("no-auth") Basic = authType("basic") Beared = authType("bearer") Digest = authType("digest") )
var ( GlobalNamespace = Namespace{ BucketName: DefaultScopeOrCollection, ScopeName: DefaultScopeOrCollection, } )
Functions ¶
func AppLocationInQuery ¶
func GetDeploymentConfig ¶
GetDeploymentConfig will unmarshal the bytes and return deployment config and binding list Unmarshaling is of the old format and not the new format
func GetLogDirectoryAndFileName ¶
func GetLogDirectoryAndFileName(funcDetails *FunctionDetails, eventingDir string) (dirName, fileName string)
func NamespaceInQuery ¶
func PossibleStateChange ¶
func QueryMap ¶
func QueryMap(appLocation AppLocation) map[string][]string
func QueryMapNamesapce ¶
func ValidateSettings ¶
validateSettings will validate the settings fields provided in the settings map. allowedFields check which all fields are allowed. If "*" is present then all fields are allowed except "-settings.%s" fields provided in the allowedFields map.
Types ¶
type AppLocation ¶
type AppLocation struct { Namespace Namespace `json:"function_scope"` Appname string `json:"app_name"` }
Implement AppLocation and its functions
func GetApplocation ¶
func GetApplocation(params map[string][]string) (appLocation AppLocation)
func NewAppLocation ¶
func NewAppLocation(appName string, bucketName, scopeName string) (applocation AppLocation, err error)
func StringToAppLocation ¶
func StringToAppLocation(location string) (appLocation AppLocation)
func (AppLocation) Clone ¶
func (appLocation AppLocation) Clone() (clone AppLocation)
func (AppLocation) String ¶
func (appLocation AppLocation) String() string
func (AppLocation) ToLocationString ¶
func (appLocation AppLocation) ToLocationString() string
type AppState ¶
type AppState struct { ProcessingState bool `json:"processing_status"` DeploymentState bool `json:"deployment_status"` }
Implement AppState and its function
func (AppState) GetLifeCycle ¶
func (e AppState) GetLifeCycle() LifeCycleOp
func (*AppState) UnmarshalJSON ¶
type AppVersion ¶
type AppVersion uint8
const ( // Old format Version1 AppVersion = iota // New format Version2 )
type Application ¶
type Application interface { // VerifyAndMergeDepCfg merges when all the checks passed for deployment config VerifyAndMergeDepCfg(allowedFields map[string]struct{}, newDepcfg DepCfg, bindings []Bindings) (bool, error) // VerifyAndMergeSettings merges when all the checks passed for settings VerifyAndMergeSettings(allowedFields map[string]struct{}, settings map[string]interface{}) (bool, error) // Returns storage bytes for the Application GetStorageBytes(sc StorageConfig) StorageBytes // Returns Rest api format as provided by version GetAppBytes(v AppVersion) (json.Marshaler, error) // GetSourceAndDestinations returns source and destination keyspace GetSourceAndDestinations(srcCheck bool) (src Keyspace, dsts map[Keyspace]Writer, err error) // GetRequestType returns the kind of source from which function needs to be executed GetRequestType() requestType // Clone returns duplicate FunctionDetails Clone(redact bool) *FunctionDetails // ModifyAppCode will modify the code to suitable for running in v8 ModifyAppCode(modify bool) string // IsSourceMutationPossible returns true if source bucket mutation is possible IsSourceMutationPossible() bool }
NewApplcation(fBytes []byte, byteSource source)
type Bindings ¶
type Bindings struct { BindingType bindingType `json:"binding_type"` CurlBinding *CurlBinding `json:"curl_binding,omitempty"` BucketBinding *BucketBinding `json:"bucket_binding,omitempty"` ConstantBinding *ConstantBinding `json:"constant_binding,omitempty"` }
func NewBucketBinding ¶
func NewConstantBinding ¶
func NewConstantBinding(constant *ConstantBinding) (Bindings, error)
func NewCurlBinding ¶
func NewCurlBinding(curlBinding *CurlBinding) (Bindings, error)
func (Bindings) ExactEquals ¶
type BucketBinding ¶
type BucketBinding struct { Alias string `json:"alias"` Keyspace Keyspace `json:"keyspace"` AccessType access `json:"access"` }
func (*BucketBinding) Clone ¶
func (bb *BucketBinding) Clone() (clone *BucketBinding)
func (*BucketBinding) ExactEquals ¶
func (bb *BucketBinding) ExactEquals(obb *BucketBinding) bool
func (BucketBinding) String ¶
func (b BucketBinding) String() string
type ConstantBinding ¶
func (*ConstantBinding) Clone ¶
func (cb *ConstantBinding) Clone() (clone *ConstantBinding)
func (*ConstantBinding) ExactEquals ¶
func (cb *ConstantBinding) ExactEquals(ocb *ConstantBinding) bool
func (ConstantBinding) String ¶
func (c ConstantBinding) String() string
type CurlBinding ¶
type CurlBinding struct { HostName string `json:"hostname"` Alias string `json:"value"` AuthType authType `json:"auth_type"` AllowCookie bool `json:"allow_cookies"` ValidateSSL bool `json:"validate_ssl_certificate"` UserName string `json:"username"` Password string `json:"password"` BearerKey string `json:"bearer_key"` }
func (*CurlBinding) Clone ¶
func (cb *CurlBinding) Clone(redact bool) (clone *CurlBinding)
func (*CurlBinding) ExactEquals ¶
func (cb *CurlBinding) ExactEquals(ocb *CurlBinding) bool
func (CurlBinding) String ¶
func (c CurlBinding) String() string
type DepCfg ¶
type DepCfg struct { SourceKeyspace Keyspace `json:"source_keyspace"` MetaKeyspace Keyspace `json:"meta_keyspace"` }
Implement DepCfg and its function
func (DepCfg) RequestType ¶
func (depcfg DepCfg) RequestType() requestType
type FunctionDetails ¶
type FunctionDetails struct { Version int8 `json:"version"` AppLocation AppLocation `json:"app_location"` AppCode string `json:"app_code"` AppID uint32 `json:"function_id"` AppInstanceID string `json:"function_instance_id"` Settings HandlerSettings `json:"settings"` AppState AppState `json:"app_state"` DeploymentConfig DepCfg `json:"depcfg"` Bindings []Bindings `json:"bindings"` MetaInfo MetaInfo `json:"metainfo"` Owner Owner `json:"owner,omitempty"` // contains filtered or unexported fields }
func NewApplication ¶
func NewApplication(sb StorageBytes, byteSource source) (funcDetails *FunctionDetails, err error)
NewApplication will unmarshal the StorageBytes with respect to provided byteSoruce and return FunctionDetails
func NewApplicationList ¶
func NewApplicationList(sb StorageBytes, byteSource source) (funcList []*FunctionDetails, err error)
NewApplicationListb will unmarshal the storageBytes with respect to byteSource and return list of FunctionDetails
func (*FunctionDetails) Clone ¶
func (fd *FunctionDetails) Clone(redact bool) *FunctionDetails
Clone will return cloned FunctionDetails
func (*FunctionDetails) GetAppBytes ¶
func (fd *FunctionDetails) GetAppBytes(v AppVersion) (json.Marshaler, error)
func (*FunctionDetails) GetDestinationKeyspace ¶
func (fd *FunctionDetails) GetDestinationKeyspace(srcCheck bool) (dsts map[Keyspace]Writer, err error)
func (*FunctionDetails) GetRequestType ¶
func (fd *FunctionDetails) GetRequestType() requestType
func (*FunctionDetails) GetSourceAndDestinations ¶
func (*FunctionDetails) GetStorageBytes ¶
func (fd *FunctionDetails) GetStorageBytes(sc StorageConfig) StorageBytes
func (*FunctionDetails) IsSourceMutationPossible ¶
func (fd *FunctionDetails) IsSourceMutationPossible() bool
func (*FunctionDetails) ModifyAppCode ¶
func (fd *FunctionDetails) ModifyAppCode(modify bool) string
func (FunctionDetails) String ¶
func (f FunctionDetails) String() string
func (*FunctionDetails) ValidateBinding ¶
func (nFuncDetails *FunctionDetails) ValidateBinding(possibleChanges map[string]struct{}, oldBindings []Bindings) (changed bool, err error)
func (*FunctionDetails) VerifyAndMergeDepCfg ¶
func (*FunctionDetails) VerifyAndMergeSettings ¶
func (fd *FunctionDetails) VerifyAndMergeSettings(allowedFields map[string]struct{}, settings map[string]interface{}) (changed bool, err error)
type HandlerSettings ¶
type HandlerSettings struct { LanguageRuntimeSettings InitSettings }
func DefaultSettings ¶
func DefaultSettings() HandlerSettings
func (HandlerSettings) Clone ¶
func (hs HandlerSettings) Clone() HandlerSettings
func (HandlerSettings) String ¶
func (h HandlerSettings) String() string
func (*HandlerSettings) UnmarshalJSON ¶
func (hs *HandlerSettings) UnmarshalJSON(b []byte) error
type InitSettings ¶
type InitSettings struct { CppWorkerThread uint32 `json:"cpp_worker_thread_count"` DcpStreamBoundary streamBoundary `json:"dcp_stream_boundary"` Description string `json:"description"` LogLevel LogLevel `json:"log_level"` NumTimerPartition uint16 `json:"num_timer_partitions"` StatsDuration uint64 `json:"tick_duration"` TimerContextSize uint32 `json:"timer_context_size"` WorkerCount uint32 `json:"worker_count"` AppLogDir string `json:"app_log_dir"` EnableAppRotation bool `json:"enable_applog_rotation"` AppLogMaxSize uint64 `json:"app_log_max_size"` AppLogMaxFiles uint32 `json:"app_log_max_files"` CheckpointInterval uint64 `json:"checkpoint_interval"` CursorAware bool `json:"cursor_aware"` AllowSyncDocuments bool `json:"allow_sync_documents"` AllowTransactionDocument bool `json:"allow_transaction_mutations"` CheckInterval uint64 `json:"high_seq_check_interval"` MaxUnackedBytes float64 `json:"max_unacked_bytes"` MaxUnackedCount float64 `json:"max_unacked_count"` FlushTimer uint64 `json:"message_flush_time"` MaxParallelVb uint16 `json:"max_parallel_vb"` }
type Keyspace ¶
func NewKeyspace ¶
func (Keyspace) ExactEquals ¶
func (Keyspace) IsWildcard ¶
func (Keyspace) RequestType ¶
func (ks Keyspace) RequestType() requestType
type KeyspaceInfo ¶
type KeyspaceInfo struct { UID string CollectionID string ScopeID string BucketID string NumVbuckets uint16 }
func GetKeyspaceInfoFromString ¶
func GetKeyspaceInfoFromString(keyspace string) (KeyspaceInfo, error)
func NewKeyspaceInfo ¶
func NewKeyspaceInfo(UID, bucketID, scopeID, collectionID string, numVbuckets uint16) (keyspaceInfo KeyspaceInfo)
func (KeyspaceInfo) Clone ¶
func (k KeyspaceInfo) Clone() (clone KeyspaceInfo)
func (KeyspaceInfo) ExactEquals ¶
func (k KeyspaceInfo) ExactEquals(ok KeyspaceInfo) bool
func (KeyspaceInfo) Match ¶
func (k KeyspaceInfo) Match(ok KeyspaceInfo) bool
func (KeyspaceInfo) String ¶
func (k KeyspaceInfo) String() string
type LanguageRuntimeSettings ¶
type LanguageRuntimeSettings struct { ExecutionTimeout uint64 `json:"execution_timeout"` OnDeployTimeout uint64 `json:"on_deploy_timeout"` CursorCheckpointTimeout uint64 `json:"cursor_checkpoint_timeout"` LanguageCompat langCompat `json:"language_compatibility"` LcbInstCapacity uint32 `json:"lcb_inst_capacity"` LcbRetryCount uint32 `json:"lcb_retry_count"` LcbTimeout uint64 `json:"lcb_timeout"` N1qlConsistency n1qlConsistency `json:"n1ql_consistency"` N1qlPrepare bool `json:"n1ql_prepare_all"` HandlerHeader []string `json:"handler_headers"` BucketCacheSize uint64 `json:"bucket_cache_size"` BucketCacheAge uint64 `json:"bucket_cache_age"` CurlRespSize uint64 `json:"curl_max_allowed_resp_size"` }
type LifeCycleOp ¶
type LifeCycleOp uint8
const ( Undeploy LifeCycleOp = iota //00 Pause // 01 InvalidState // 10 Deploy // 11 NoLifeCycleOp // invalid )
func (LifeCycleOp) String ¶
func (l LifeCycleOp) String() string
type MetaInfo ¶
type MetaInfo struct { RequestType requestType FunctionScopeID KeyspaceInfo MetaID KeyspaceInfo SourceID KeyspaceInfo IsUsingTimer bool Seq uint32 LastPaused time.Time Sboundary streamBoundary }
MetaInfo contains internal info related to function This must be populated with appropriate field from the caller
type Namespace ¶
type Namespace struct { BucketName string `json:"bucket_name"` ScopeName string `json:"scope_name"` }
Implements Namespace and related functions
func NewNamespace ¶
func (Namespace) ExactEquals ¶
func (Namespace) IsWildcard ¶
func (Namespace) ToOldNamespace ¶
func (ns Namespace) ToOldNamespace() OldNamespace
type OldApplication ¶
type OldApplication struct { AppCode string `json:"appcode"` DeploymentConfig depCfg `json:"depcfg"` EventingVersion string `json:"version"` EnforceSchema bool `json:"enforce_schema"` FunctionID uint32 `json:"handleruuid"` FunctionInstanceID string `json:"function_instance_id"` AppName string `json:"appname"` Settings map[string]interface{} `json:"settings"` Metainfo map[string]interface{} `json:"metainfo,omitempty"` FunctionScope OldNamespace `json:"function_scope"` Owner *Owner `json:"owner,omitempty"` // Don't expose. Only used for unmarshaling }
Old style application
type OldNamespace ¶
For backward compatibility
type State ¶
type State uint8
func BootstrappingStatus ¶
func GetStateFromLifeCycle ¶
func GetStateFromLifeCycle(op LifeCycleOp) State