istructsmem

package
v1.202405300917.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 32 Imported by: 0

README

codecov

Events

  • istructsmem.eventType

    • Represents event builders (IRawEventBuilder and IRawEventBuilder) and events (IAbstractEvent, IDbEvent and other)
  • istructsmem.appEventsType

    • Represents IEvents

    • appEventsType.GetSyncRawEventBuilder

      • Returns Synced raw event builder
    • appEventsType.PutPlog

      • Saves IRawEvent and return IPLogEvent
      • Argument is cloned and saved
    • appEventsType.PutPlog

      • Saves IPLogEvent and return IWLogEvent
      • Event entities are cloned and saved
    • appEventsType.ReadPLog

      • Reads PLog from specified offset to specified event count by callback function
    • appEventsType.ReadWLog

      • Reads WLog from specified offset to specified event count by callback function

Records

  • istructsmem.recordType

    • represents IRecord and other records
  • istructsmem.appRecordsType

    • represents IRecords

    • appRecordsType.Apply

      • Saves IPLogEvent CUDs records and returns IRecords by callback function
    • appRecordsType.Read

      • Reads record from storage by specified ID and returns IRecord

Views

  • istructsmem.viewRecordType

    • represents IKeyBuilder
  • istructsmem.appViewRecordsType

    • represents IViewRecords

    • appViewRecordsType.KeyBuilder

      • Returns new key builder for specified view
    • appViewRecordsType.NewValueBuilder

      • Returns new empty view value builder for specified view
    • appViewRecordsType.UdateValueBuilder

      • Returns new view value builder for specified view assigned from specified exists view value
    • appViewRecordsType.Put

      • Puts view record (key and value) into the storage
    • appViewRecordsType.Read

      • Reads view records (key and value) for specified key from the storage by calling callback function.
      • Key may be build partially. In this case all view records, witch keys starts with specified key, will be reads

Documentation

Overview

* Copyright (c) 2021-present Sigma-Soft, Ltd. * @author: Nikolay Nikitin

Index

Constants

View Source
const (
	ECode_UnknownError = iota

	ECode_EmptyTypeName
	ECode_InvalidTypeName
	ECode_InvalidTypeKind

	ECode_EmptyData

	ECode_InvalidRecordID
	ECode_InvalidRefRecordID

	ECode_EEmptyCUDs

	ECode_InvalidChildName
	ECode_InvalidOccursMin
	ECode_InvalidOccursMax
)

validate error codes, see ValidateError.Code()

View Source
const (
	// events per application plog cache, see [#455](https://github.com/voedger/voedger/issues/455#:~:text=Currently%2C%2010000%20must%20be%20used)
	DefaultPLogEventCacheSize = 10 * 1000
)

Application config

Variables

View Source
var ErrAbstractType = errors.New("abstract type")
View Source
var ErrCUDsMissed = errors.New("CUDs are missed")
View Source
var ErrDataConstraintViolation = errors.New("data constraint violation")
View Source
var ErrFieldIsEmpty = errors.New("field is empty")
View Source
var ErrIDNotFound = errors.New("ID not found")
View Source
var ErrInvalidName = errors.New("name not valid")
View Source
var ErrInvalidVerificationKind = errors.New("invalid verification kind")
View Source
var ErrMaxGetBatchRecordCountExceeds = errors.New("the maximum count of records to batch is exceeded")
View Source
var ErrMaxOccursViolation = errors.New("maximum occurs violated")
View Source
var ErrMinOccursViolation = errors.New("minimum occurs violated")
View Source
var ErrNameMissed = errors.New("name is empty")
View Source
var ErrNameNotFound = errors.New("name not found")
View Source
var ErrNumAppWorkspacesNotSet = errors.New("NumAppWorkspaces is not set")
View Source
var ErrRawRecordIDRequired = errors.New("raw record ID required")
View Source
var ErrRawRecordIDUnexpected = errors.New("unexpected raw record ID")
View Source
var ErrRecordIDNotFound = fmt.Errorf("recordID cannot be found: %w", ErrIDNotFound)
View Source
var ErrRecordIDUniqueViolation = errors.New("record ID duplicates")
View Source
var ErrRecordNotFound = errors.New("record cannot be found")
View Source
var ErrTypeChanged = errors.New("type has been changed")
View Source
var ErrUnableToUpdateSystemField = errors.New("unable to update system field")
View Source
var ErrUnexpectedTypeKind = errors.New("unexpected type kind")
View Source
var ErrUnknownCodec = errors.New("unknown codec")
View Source
var ErrWrongFieldType = errors.New("wrong field type")
View Source
var ErrWrongRecordID = errors.New("wrong record ID")
View Source
var ErrWrongType = errors.New("wrong type")
View Source
var ErrorEventNotValid = errors.New("event is not valid")
View Source
var MatchAll = func(_ appdef.QName, _ istructs.WSID, _ appdef.QName) bool {
	return true
}
View Source
var NullAppConfig = newAppConfig(istructs.AppQName_null, appdef.New())

Functions

func GetFunctionRateLimitName

func GetFunctionRateLimitName(funcQName appdef.QName, rateLimitKind istructs.RateLimitKind) (res string)

func IBucketsFromIAppStructs

func IBucketsFromIAppStructs(as istructs.IAppStructs) irates.IBuckets

func NewCommandFunction

func NewCommandFunction(name appdef.QName, exec ExecCommandClosure) istructs.ICommandFunction

NewCommandFunction creates and returns new command function

func NewIDGenerator

func NewIDGenerator() istructs.IIDGenerator

func NewIDGeneratorWithHook

func NewIDGeneratorWithHook(onNewID func(rawID, storageID istructs.RecordID, t appdef.IType) error) istructs.IIDGenerator

used in tests

func NewNullRecord

func NewNullRecord(id istructs.RecordID) istructs.IRecord

func NewQueryFunction

func NewQueryFunction(name appdef.QName, exec ExecQueryClosure) istructs.IQueryFunction

Creates and returns new query function

func NewQueryFunctionCustomResult

func NewQueryFunctionCustomResult(name appdef.QName, resultFunc func(istructs.PrepareArgs) appdef.QName, exec ExecQueryClosure) istructs.IQueryFunction

func NullCommandExec

func NullCommandExec(_ istructs.ExecCommandArgs) error

NullCommandExec is null execute action closure for command functions

func NullQueryExec

Null execute action closure for query functions

func Provide

func Provide(appConfigs AppConfigsType, bucketsFactory irates.BucketsFactoryType, appTokensFactory payloads.IAppTokensFactory,
	storageProvider istorage.IAppStorageProvider) (provider istructs.IAppStructsProvider)

Provide: constructs new application structures provider

Types

type AppConfigParams

type AppConfigParams struct {
	// PLog events cache size.
	//
	// Default value is DefaultPLogEventCacheSize (10’000 events).
	// Zero (0) means that cache will not be used
	PLogEventCacheSize int
}

Application configuration parameters

type AppConfigType

type AppConfigType struct {
	Name         istructs.AppQName
	ClusterAppID istructs.ClusterAppID

	AppDef    appdef.IAppDef
	Resources Resources

	// Application configuration parameters
	Params AppConfigParams

	FunctionRateLimits functionRateLimits
	// contains filtered or unexported fields
}

AppConfigType: configuration for application workflow

func (*AppConfigType) AddAsyncProjectors

func (cfg *AppConfigType) AddAsyncProjectors(pp ...istructs.Projector)

func (*AppConfigType) AddCUDValidators

func (cfg *AppConfigType) AddCUDValidators(cudValidators ...istructs.CUDValidator)

func (*AppConfigType) AddEventValidators

func (cfg *AppConfigType) AddEventValidators(eventValidators ...istructs.EventValidator)

func (*AppConfigType) AddSyncProjectors

func (cfg *AppConfigType) AddSyncProjectors(pp ...istructs.Projector)

func (*AppConfigType) AppDefBuilder

func (cfg *AppConfigType) AppDefBuilder() appdef.IAppDefBuilder

need to build view.sys.NextBaseWSID and view.sys.projectionOffsets could be called on application build stage only

func (*AppConfigType) AsyncProjectors

func (cfg *AppConfigType) AsyncProjectors() istructs.Projectors

func (*AppConfigType) NumAppWorkspaces

func (cfg *AppConfigType) NumAppWorkspaces() istructs.NumAppWorkspaces

func (*AppConfigType) Prepared

func (cfg *AppConfigType) Prepared() bool

Returns is application configuration prepared

func (*AppConfigType) SetNumAppWorkspaces

func (cfg *AppConfigType) SetNumAppWorkspaces(naw istructs.NumAppWorkspaces)

must be called after creating the AppConfigType because app will provide the deployment descriptor with the actual NumAppWorkspaces after willing the AppConfigType so fisrt create AppConfigType, use it on app provide, then set the actual NumAppWorkspaces

func (*AppConfigType) SyncProjectors

func (cfg *AppConfigType) SyncProjectors() istructs.Projectors

type AppConfigsType

type AppConfigsType map[istructs.AppQName]*AppConfigType

AppConfigsType: map of applications configurators

func (*AppConfigsType) AddConfig

func (cfgs *AppConfigsType) AddConfig(appName istructs.AppQName, appDef appdef.IAppDefBuilder) *AppConfigType

AddConfig: adds new config for specified application or replaces if exists

func (*AppConfigsType) GetConfig

func (cfgs *AppConfigsType) GetConfig(appName istructs.AppQName) *AppConfigType

GetConfig: gets config for specified application

type ExecCommandClosure

type ExecCommandClosure func(args istructs.ExecCommandArgs) (err error)

Function type to call for command execute action

type ExecQueryClosure

type ExecQueryClosure func(ctx context.Context, args istructs.ExecQueryArgs, callback istructs.ExecQueryCallback) (err error)

Function type to call for query execute action

type Resources

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

Implements istructs.IResources

func (*Resources) Add

func (res *Resources) Add(r istructs.IResource)

Adds new resource to application resources

func (*Resources) QueryResource

func (res *Resources) QueryResource(resource appdef.QName) (r istructs.IResource)

Finds application resource by QName

func (*Resources) Resources

func (res *Resources) Resources(enum func(appdef.QName))

Enumerates all application resources

type ValidateError

type ValidateError interface {
	error
	Code() int
}

ValidateError: an interface for describing errors that occurred during validation

  • methods: — Code(): returns error code, see ECode_××× constants

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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