artifactmanager

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package artifactmanager provides high-level storage API for logic runner module.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRef        = errors.New("invalid reference")
	ErrObjectDeactivated = errors.New("object is deactivated")
	ErrNotFound          = errors.New("object not found")
)

Custom errors possibly useful to check by artifact manager callers.

Functions

func Build added in v0.7.5

func Build(handler core.MessageHandler, wrapHandlers ...Handler) core.MessageHandler

Build return wrapping core.MessageHandler If want call wrapHandler1(wrapHandler2(wrapHandler3(handler))), we should use Build(handler, wrapHandler1, wrapHandler2, wrapHandler3).

Types

type ChildIterator added in v0.5.0

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

ChildIterator is used to iterate over objects children. During iteration children refs will be fetched from remote source (parent object).

Data can be fetched only from Active Executor (AE), although children references can be stored on other nodes. To cope with this, we have a token system. Every time AE doesn't have data and asked for it, it will issue a token that will allow requester to fetch data from a different node. This node will return all children references it has, after which the requester has to go to AE again to fetch a new token. It will then be redirected to another node. E.i. children fetching happens like this: [R = requester, AE = active executor, LE = any light executor that has data, H = heavy executor] 1. R (get children 0 ... ) -> AE 2. AE (children 0 ... 3) -> R 3. R (get children 4 ...) -> AE 4. AE (redirect to LE) -> R 5. R (get children 4 ...) -> LE 6. LE (children 4 ... 5) -> R 7. R (get children 6 ...) -> AE 8. AE (redirect to H) -> R 9. R (get children 6 ...) -> H 10. H (children 6 ... 15 EOF) -> R

func NewChildIterator added in v0.5.0

func NewChildIterator(
	ctx context.Context,
	mb core.MessageBus,
	db *storage.DB,
	parent core.RecordRef,
	fromPulse *core.PulseNumber,
	chunkSize int,
	currentPulse core.Pulse,
) (*ChildIterator, error)

NewChildIterator creates new child iterator.

func (*ChildIterator) HasNext added in v0.5.0

func (i *ChildIterator) HasNext() bool

HasNext checks if any elements left in iterator.

func (*ChildIterator) Next added in v0.5.0

func (i *ChildIterator) Next() (*core.RecordRef, error)

Next returns next element.

type CodeDescriptor added in v0.0.5

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

CodeDescriptor represents meta info required to fetch all code data.

func (*CodeDescriptor) Code added in v0.0.5

func (d *CodeDescriptor) Code() ([]byte, error)

Code returns code data.

func (*CodeDescriptor) MachineType added in v0.0.6

func (d *CodeDescriptor) MachineType() core.MachineType

MachineType returns code machine type for represented code.

func (*CodeDescriptor) Ref added in v0.0.5

func (d *CodeDescriptor) Ref() *core.RecordRef

Ref returns reference to represented code record.

type Handler added in v0.7.5

type Handler func(core.MessageHandler) core.MessageHandler

Alias for wrapping func-s

type HotDataWaiter added in v0.7.5

type HotDataWaiter interface {
	Wait(ctx context.Context, jetID core.RecordID) error
	Unlock(ctx context.Context, jetID core.RecordID)
	ThrowTimeout(ctx context.Context)
}

HotDataWaiter provides waiting system for a specific jet We tend to think, that it will be used for waiting hot-data in handler Also, because of the some jet pitfalls, we need to have an instrument to handler edge-cases from pulse manager. The main case is when a light material executes a jet for more then 1 pulse If it happens, we need to stop waiters from raising and waiting

type HotDataWaiterConcrete added in v0.7.5

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

HotDataWaiterConcrete is an implementation of HotDataWaiter

func NewHotDataWaiterConcrete added in v0.7.5

func NewHotDataWaiterConcrete() *HotDataWaiterConcrete

NewHotDataWaiterConcrete is a constructor

func (*HotDataWaiterConcrete) ThrowTimeout added in v0.7.5

func (hdw *HotDataWaiterConcrete) ThrowTimeout(ctx context.Context)

ThrowTimeout raises all timeoutChannel

func (*HotDataWaiterConcrete) Unlock added in v0.7.5

func (hdw *HotDataWaiterConcrete) Unlock(ctx context.Context, jetID core.RecordID)

Unlock raises hotDataChannel

func (*HotDataWaiterConcrete) Wait added in v0.7.5

func (hdw *HotDataWaiterConcrete) Wait(ctx context.Context, jetID core.RecordID) error

Wait waits for the raising one of two channels. If hotDataChannel or timeoutChannel was raised, the method returns error Either nil or ErrHotDataTimeout

type LedgerArtifactManager

type LedgerArtifactManager struct {
	DefaultBus                 core.MessageBus                 `inject:""`
	PlatformCryptographyScheme core.PlatformCryptographyScheme `inject:""`
	PulseStorage               core.PulseStorage               `inject:""`
	JetCoordinator             core.JetCoordinator             `inject:""`
	// contains filtered or unexported fields
}

LedgerArtifactManager provides concrete API to storage for processing module.

func NewArtifactManger added in v0.0.5

func NewArtifactManger(db *storage.DB) *LedgerArtifactManager

NewArtifactManger creates new manager instance.

func (*LedgerArtifactManager) ActivateObject added in v0.3.0

func (m *LedgerArtifactManager) ActivateObject(
	ctx context.Context,
	domain, object, parent, prototype core.RecordRef,
	asDelegate bool,
	memory []byte,
) (core.ObjectDescriptor, error)

ActivateObject creates activate object record in storage. Provided prototype reference will be used as objects prototype memory as memory of created object. If memory is not provided, the prototype default memory will be used.

Request reference will be this object's identifier and referred as "object head".

func (*LedgerArtifactManager) ActivatePrototype added in v0.6.2

func (m *LedgerArtifactManager) ActivatePrototype(
	ctx context.Context,
	domain, object, parent, code core.RecordRef,
	memory []byte,
) (core.ObjectDescriptor, error)

ActivatePrototype creates activate object record in storage. Provided prototype reference will be used as objects prototype memory as memory of created object. If memory is not provided, the prototype default memory will be used.

Request reference will be this object's identifier and referred as "object head".

func (*LedgerArtifactManager) DeactivateObject added in v0.3.0

func (m *LedgerArtifactManager) DeactivateObject(
	ctx context.Context, domain, request core.RecordRef, object core.ObjectDescriptor,
) (*core.RecordID, error)

DeactivateObject creates deactivate object record in storage. Provided reference should be a reference to the head of the object. If object is already deactivated, an error should be returned.

Deactivated object cannot be changed.

func (*LedgerArtifactManager) DeclareType added in v0.0.5

func (m *LedgerArtifactManager) DeclareType(
	ctx context.Context, domain, request core.RecordRef, typeDec []byte,
) (*core.RecordID, error)

DeclareType creates new type record in storage.

Type is a contract interface. It contains one method signature.

func (*LedgerArtifactManager) DeployCode

func (m *LedgerArtifactManager) DeployCode(
	ctx context.Context,
	domain core.RecordRef,
	request core.RecordRef,
	code []byte,
	machineType core.MachineType,
) (*core.RecordID, error)

DeployCode creates new code record in storage.

CodeRef records are used to activate prototype or as migration code for an object.

func (*LedgerArtifactManager) GenesisRef added in v0.6.0

func (m *LedgerArtifactManager) GenesisRef() *core.RecordRef

GenesisRef returns the root record reference.

Root record is the parent for all top-level records.

func (*LedgerArtifactManager) GetChildren added in v0.5.0

func (m *LedgerArtifactManager) GetChildren(
	ctx context.Context, parent core.RecordRef, pulse *core.PulseNumber,
) (core.RefIterator, error)

GetChildren returns children iterator.

During iteration children refs will be fetched from remote source (parent object).

func (*LedgerArtifactManager) GetCode added in v0.0.5

GetCode returns code from code record by provided reference according to provided machine preference.

This method is used by VM to fetch code for execution.

func (*LedgerArtifactManager) GetDelegate added in v0.3.0

func (m *LedgerArtifactManager) GetDelegate(
	ctx context.Context, head, asType core.RecordRef,
) (*core.RecordRef, error)

GetDelegate returns provided object's delegate reference for provided prototype.

Object delegate should be previously created for this object. If object delegate does not exist, an error will be returned.

func (*LedgerArtifactManager) GetObject added in v0.3.0

func (m *LedgerArtifactManager) GetObject(
	ctx context.Context,
	head core.RecordRef,
	state *core.RecordID,
	approved bool,
) (core.ObjectDescriptor, error)

GetObject returns descriptor for provided state.

If provided state is nil, the latest state will be returned (with deactivation check). Returned descriptor will provide methods for fetching all related data.

func (*LedgerArtifactManager) HasPendingRequests added in v0.7.5

func (m *LedgerArtifactManager) HasPendingRequests(
	ctx context.Context,
	object core.RecordRef,
) (bool, error)

HasPendingRequests returns true if object has unclosed requests.

func (*LedgerArtifactManager) RegisterRequest added in v0.5.0

func (m *LedgerArtifactManager) RegisterRequest(
	ctx context.Context, obj core.RecordRef, parcel core.Parcel,
) (*core.RecordID, error)

RegisterRequest sends message for request registration, returns request record Ref if request successfully created or already exists.

func (*LedgerArtifactManager) RegisterResult added in v0.6.2

func (m *LedgerArtifactManager) RegisterResult(
	ctx context.Context, object, request core.RecordRef, payload []byte,
) (*core.RecordID, error)

RegisterResult saves VM method call result.

func (*LedgerArtifactManager) RegisterValidation added in v0.6.2

func (m *LedgerArtifactManager) RegisterValidation(
	ctx context.Context,
	object core.RecordRef,
	state core.RecordID,
	isValid bool,
	validationMessages []core.Message,
) error

RegisterValidation marks provided object state as approved or disapproved.

When fetching object, validity can be specified.

func (*LedgerArtifactManager) State added in v0.6.3

func (m *LedgerArtifactManager) State() ([]byte, error)

State returns hash state for artifact manager.

func (*LedgerArtifactManager) UpdateObject added in v0.3.0

func (m *LedgerArtifactManager) UpdateObject(
	ctx context.Context,
	domain, request core.RecordRef,
	object core.ObjectDescriptor,
	memory []byte,
) (core.ObjectDescriptor, error)

UpdateObject creates amend object record in storage. Provided reference should be a reference to the head of the object. Provided memory well be the new object memory.

Returned reference will be the latest object state (exact) reference.

func (*LedgerArtifactManager) UpdatePrototype added in v0.6.2

func (m *LedgerArtifactManager) UpdatePrototype(
	ctx context.Context,
	domain, request core.RecordRef,
	object core.ObjectDescriptor,
	memory []byte,
	code *core.RecordRef,
) (core.ObjectDescriptor, error)

UpdatePrototype creates amend object record in storage. Provided reference should be a reference to the head of the prototype. Provided memory well be the new object memory.

Returned reference will be the latest object state (exact) reference.

type MessageHandler added in v0.4.0

type MessageHandler struct {
	RecentStorageProvider      recentstorage.Provider          `inject:""`
	Bus                        core.MessageBus                 `inject:""`
	PlatformCryptographyScheme core.PlatformCryptographyScheme `inject:""`
	JetCoordinator             core.JetCoordinator             `inject:""`
	CryptographyService        core.CryptographyService        `inject:""`
	DelegationTokenFactory     core.DelegationTokenFactory     `inject:""`
	HeavySync                  core.HeavySync                  `inject:""`
	PulseStorage               core.PulseStorage               `inject:""`
	JetStorage                 storage.JetStorage              `inject:""`
	ObjectStorage              storage.ObjectStorage           `inject:""`
	ActiveNodesStorage         storage.ActiveNodesStorage      `inject:""`
	PulseTracker               storage.PulseTracker            `inject:""`
	DBContext                  storage.DBContext               `inject:""`
	HotDataWaiter              HotDataWaiter                   `inject:""`
	// contains filtered or unexported fields
}

MessageHandler processes messages for local storage interaction.

func NewMessageHandler added in v0.4.0

func NewMessageHandler(conf *configuration.Ledger, certificate core.Certificate) *MessageHandler

NewMessageHandler creates new handler.

func (*MessageHandler) Init added in v0.6.3

func (h *MessageHandler) Init(ctx context.Context) error

Init initializes handlers and middleware.

type ObjectDescriptor

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

ObjectDescriptor represents meta info required to fetch all object data.

func (*ObjectDescriptor) ChildPointer added in v0.6.2

func (d *ObjectDescriptor) ChildPointer() *core.RecordID

ChildPointer returns the latest child for this object.

func (*ObjectDescriptor) Children added in v0.3.0

func (d *ObjectDescriptor) Children(pulse *core.PulseNumber) (core.RefIterator, error)

Children returns object's children references.

func (*ObjectDescriptor) Code added in v0.6.2

func (d *ObjectDescriptor) Code() (*core.RecordRef, error)

Code returns code reference.

func (*ObjectDescriptor) HeadRef added in v0.0.5

func (d *ObjectDescriptor) HeadRef() *core.RecordRef

HeadRef returns reference to represented object record.

func (*ObjectDescriptor) IsPrototype added in v0.6.2

func (d *ObjectDescriptor) IsPrototype() bool

IsPrototype determines if the object is a prototype.

func (*ObjectDescriptor) Memory added in v0.0.5

func (d *ObjectDescriptor) Memory() []byte

Memory fetches latest memory of the object known to storage.

func (*ObjectDescriptor) Parent added in v0.6.2

func (d *ObjectDescriptor) Parent() *core.RecordRef

Parent returns object's parent.

func (*ObjectDescriptor) Prototype added in v0.6.2

func (d *ObjectDescriptor) Prototype() (*core.RecordRef, error)

Prototype returns prototype reference.

func (*ObjectDescriptor) StateID added in v0.5.0

func (d *ObjectDescriptor) StateID() *core.RecordID

StateID returns reference to object state record.

Jump to

Keyboard shortcuts

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