batch

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 10 Imported by: 8

Documentation

Overview

Package batch batches multiple operations into batch files and stores the batch files in a distributed content-addressable storage (DCAS or CAS). A reference to the main batch file (core index) is then anchored on the anchoring system as Sidetree transaction.

Batch Writer basic flow:

1) accept operations being delivered via Add method 2) 'cut' configurable number of operations into batch files 3) store batch files into CAS (content addressable storage) 4) write the anchor string referencing core index file URI to the underlying anchoring system

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnchorWriter added in v0.6.0

type AnchorWriter interface {
	// WriteAnchor writes the anchor string as a transaction to anchoring system
	WriteAnchor(anchor string, artifacts []*protocol.AnchorDocument, ops []*operation.Reference, protocolVersion uint64) error
	// Read ledger transaction
	Read(sinceTransactionNumber int) (bool, *txn.SidetreeTxn)
}

AnchorWriter defines an interface to access the underlying anchoring system.

type CompressionProvider added in v0.1.4

type CompressionProvider interface {

	// Compress will compress data using specified algorithm.
	Compress(alg string, data []byte) ([]byte, error)
}

CompressionProvider defines an interface for handling different types of compression.

type Context

type Context interface {
	Protocol() protocol.Client
	Anchor() AnchorWriter
	OperationQueue() cutter.OperationQueue
}

Context contains batch writer context. 1) protocol information client 2) content addressable storage client 3) anchor writer.

type Option

type Option func(opts *Options) error

Option defines Writer options such as batch timeout.

func WithBatchTimeout

func WithBatchTimeout(batchTimeout time.Duration) Option

WithBatchTimeout allows for specifying batch timeout.

func WithMonitorInterval added in v1.0.0

func WithMonitorInterval(interval time.Duration) Option

WithMonitorInterval specifies the interval in which the operation queue is monitored in order to see if the maximum batch size has been reached.

type Options

type Options struct {
	BatchTimeout    time.Duration
	MonitorInterval time.Duration
}

Options allows the user to specify more advanced options.

type Writer

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

Writer implements batch writer.

func New

func New(namespace string, context Context, options ...Option) (*Writer, error)

New creates a new Writer with the given namespace. Writer accepts operations being delivered via Add, orders them, and then uses the batch cutter to form the operations batch files. The URI of main batch file (index core) will be written as part of anchor string to the given ledger.

func (*Writer) Add

func (r *Writer) Add(op *operation.QueuedOperation, protocolVersion uint64) error

Add the given operation to a queue of operations to be batched and anchored on anchoring system.

func (*Writer) Start

func (r *Writer) Start()

Start periodic anchoring of operation batches to anchoring system.

func (*Writer) Stop

func (r *Writer) Stop()

Stop frees the resources which were allocated by start.

func (*Writer) Stopped added in v0.1.3

func (r *Writer) Stopped() bool

Stopped returns true if the writer has been stopped.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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