application

package
v0.0.0-...-31abfad Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GlobalValue              = "*"
	DefaultScopeOrCollection = "_default"
)
View Source
const (
	MetaKvStore source = iota
	RestApi
)
View Source
const (
	RequestNone requestType = iota
	RequestBucket
	RequestScope
	RequestCollection
)
View Source
const (
	NoConsistency = n1qlConsistency("")
	None          = n1qlConsistency("none")
	Request       = n1qlConsistency("request")
)
View Source
const (
	Everyting = streamBoundary("everyting")
	FromNow   = streamBoundary("from_now")
	FromPrior = streamBoundary("from_prior")
)
View Source
const (
	Bucket bindingType = iota
	Curl
	Constant
)
View Source
const (
	PASSWORD_MASK = "*****"
)

Variables

View Source
var (
	ErrInvalidState          = errors.New("invalid state provided")
	ErrStateTransNotPossible = errors.New("state transition not possible")
)
View Source
var (
	NoAuth = authType("no-auth")
	Basic  = authType("basic")
	Beared = authType("bearer")
	Digest = authType("digest")
)
View Source
var (
	GlobalNamespace = Namespace{
		BucketName: DefaultScopeOrCollection,
		ScopeName:  DefaultScopeOrCollection,
	}
)

Functions

func AppLocationInQuery

func AppLocationInQuery(params map[string][]string) bool

func GetDeploymentConfig

func GetDeploymentConfig(data []byte) (newDepcfg DepCfg, bindings []Bindings, err error)

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 NamespaceInQuery(params map[string][]string) bool

func PossibleStateChange

func PossibleStateChange(currState string, event AppState) (map[string]struct{}, error)

func QueryMap

func QueryMap(appLocation AppLocation) map[string][]string

func QueryMapNamesapce

func QueryMapNamesapce(namespace Namespace) map[string][]string

func ValidateSettings

func ValidateSettings(settings map[string]interface{}) (err error)

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) Clone

func (as AppState) Clone() (clone AppState)

func (AppState) Equals

func (e AppState) Equals(e2 AppState) bool

func (AppState) GetLifeCycle

func (e AppState) GetLifeCycle() LifeCycleOp

func (AppState) String

func (a AppState) String() string

func (*AppState) UnmarshalJSON

func (as *AppState) UnmarshalJSON(b []byte) error

func (*AppState) VerifyAndMergeAppState

func (appState *AppState) VerifyAndMergeAppState(appStateMap map[string]interface{}) (bool, error)

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 NewBucketBinding(alias, bucketName, scopeName, collectionName string, accessType access) (Bindings, error)

func NewConstantBinding

func NewConstantBinding(constant *ConstantBinding) (Bindings, error)

func NewCurlBinding

func NewCurlBinding(curlBinding *CurlBinding) (Bindings, error)

func (Bindings) Clone

func (binding Bindings) Clone(redact bool) (clone Bindings)

func (Bindings) ExactEquals

func (nBinding Bindings) ExactEquals(oBinding Bindings) bool

func (Bindings) String

func (b Bindings) String() string

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

type ConstantBinding struct {
	Value string `json:"literal"`
	Alias string `json:"value"`
}

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) Clone

func (depcfg DepCfg) Clone() (clone DepCfg)

func (DepCfg) RequestType

func (depcfg DepCfg) RequestType() requestType

func (DepCfg) String

func (d DepCfg) String() string

func (*DepCfg) ValidateDeploymentConfig

func (nDepCfg *DepCfg) ValidateDeploymentConfig(possibleChanges map[string]struct{},
	deploymentConfig DepCfg) (changed bool, err error)

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 (fd *FunctionDetails) GetSourceAndDestinations(srcCheck bool) (src Keyspace, dsts map[Keyspace]Writer, err error)

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 (fd *FunctionDetails) VerifyAndMergeDepCfg(allowedFields map[string]struct{}, newDepcfg DepCfg, bindings []Bindings) (bool, error)

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

type Keyspace struct {
	Namespace
	CollectionName string `json:"collection_name"`
}

func NewKeyspace

func NewKeyspace(bucketName, scopeName, collectionName string, wildcardAllowed bool) (keyspace Keyspace, err error)

func (Keyspace) Clone

func (ks Keyspace) Clone() (clone Keyspace)

func (Keyspace) ExactEquals

func (ks1 Keyspace) ExactEquals(ks2 Keyspace) bool

func (Keyspace) IsWildcard

func (ks Keyspace) IsWildcard() bool

func (Keyspace) Match

func (ks1 Keyspace) Match(ks2 Keyspace) bool

func (Keyspace) RequestType

func (ks Keyspace) RequestType() requestType

func (Keyspace) String

func (k Keyspace) String() string

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"`
	HandlerFooter           []string        `json:"handler_footers"`
	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 LogLevel

type LogLevel 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

func (MetaInfo) Clone

func (mi MetaInfo) Clone() (clone MetaInfo)

func (MetaInfo) String

func (m MetaInfo) String() string

type Namespace

type Namespace struct {
	BucketName string `json:"bucket_name"`
	ScopeName  string `json:"scope_name"`
}

Implements Namespace and related functions

func GetNamespace

func GetNamespace(params map[string][]string, wildcard bool) (Namespace, error)

func NewNamespace

func NewNamespace(bucketName, scopeName string, wildcardAllowed bool) (Namespace, error)

func (Namespace) Clone

func (ns Namespace) Clone() (clone Namespace)

func (Namespace) ExactEquals

func (n1 Namespace) ExactEquals(n2 Namespace) bool

func (Namespace) IsWildcard

func (namespace Namespace) IsWildcard() bool

func (Namespace) Match

func (n1 Namespace) Match(n2 Namespace) bool

func (Namespace) String

func (namespace Namespace) String() string

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

type OldNamespace struct {
	BucketName string `json:"bucket"`
	ScopeName  string `json:"scope"`
}

For backward compatibility

type Owner

type Owner struct {
	User   string
	Domain string
	UUID   string
}

func (Owner) Clone

func (o Owner) Clone() (clone Owner)

func (Owner) String

func (o Owner) String() string

type State

type State uint8
const (
	NoState State = iota
	Undeployed
	Undeploying
	Deployed
	Deploying
	Paused
	Pausing
	Resuming
)

func BootstrappingStatus

func BootstrappingStatus(curr, prev State) State

func GetStateFromLifeCycle

func GetStateFromLifeCycle(op LifeCycleOp) State

func StringToAppState

func StringToAppState(state string) State

func (State) BootstrapingString

func (s State) BootstrapingString() string

func (State) IsBootstrapping

func (s State) IsBootstrapping() bool

func (State) IsDeployed

func (s State) IsDeployed() bool

func (State) IsStateTransferDone

func (s State) IsStateTransferDone() bool

func (State) String

func (s State) String() string

type StorageBytes

type StorageBytes struct {
	Body      []byte
	Sensitive []byte
}

type StorageConfig

type StorageConfig struct {
	OldStyle    bool
	TryCompress bool
	Extras      []byte
}

type Writer

type Writer int8
const (
	WriteBucket Writer = 1 << iota
	WriteN1QL
)

Jump to

Keyboard shortcuts

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