store

package
v0.0.0-...-8d7dea8 Latest Latest
Warning

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

Go to latest
Published: May 19, 2019 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventStore

type EventStore struct {
	Filename          string
	UseCompression    bool
	SnapshotDirectory string
	// contains filtered or unexported fields
}

func (*EventStore) PersistEvent

func (es *EventStore) PersistEvent(e core.Event) error

func (*EventStore) PersistSnapshot

func (es *EventStore) PersistSnapshot(zoneID uuid.UUID, seqNum uint64, snapEvents []core.Event) error

func (*EventStore) RetrieveAll

func (es *EventStore) RetrieveAll() (<-chan rpc.Response, error)

func (*EventStore) RetrieveAllEventsForZone

func (es *EventStore) RetrieveAllEventsForZone(zoneID uuid.UUID) (<-chan rpc.Response, error)

func (*EventStore) RetrieveEventsUpToSequenceNumForZone

func (es *EventStore) RetrieveEventsUpToSequenceNumForZone(endNum uint64, zoneID uuid.UUID) (<-chan rpc.Response, error)

type FromDomainer

type FromDomainer interface {
	FromDomain(core.Event)
	Header() eventHeader
}

type IntentLogger

type IntentLogger struct {
	Filename string
	// contains filtered or unexported fields
}

IntentLogger is a change-intent-log, useful for implementing transactional semantics for a higher-level store. By first making a record of the changes you intend to make (and optionally a record of how to un-do those changes), and later making a record of the successful completion of those changes, IntentLogger has enough information to later detect and give you context for any changes that weren't complete at the time of a crash.

Normal use works like this:

1- create a new log using IntentLogger.Open()

2- write an intent using IntentLogger.WriteIntent(); this returns a transaction ID you must store

3- execute your intended changes as usual

4- confirm the original intent has been completed using IntentLogger.ConfirmIntentCompletion()

5- (optional) close the log using IntentLogger.Close()

6- on re-start, call IntentLogger.Open() again; this time, the callback func you provide will be called for each intent that was successfully written to the log but never marked as complete later on

Some notes on semantics:

* WriteIntent() and ConfirmIntentCompletion() call io.Sync() before returning.

* After each successful call to the handler provided to Open(), it automatically calls ConfirmIntentCompletion().

* Open() will truncate any trailing+incomplete entries it finds while reading the input stream.

func (*IntentLogger) Close

func (il *IntentLogger) Close()

Close calls os.File.Close() and resets internal state to that of a new IntentLogger.

func (IntentLogger) ConfirmIntentCompletion

func (il IntentLogger) ConfirmIntentCompletion(transactionID uuid.UUID) error

ConfirmIntentCompletion writes a completion-marker for the intent-entry with the given ID.

func (*IntentLogger) Open

func (il *IntentLogger) Open(handler func(redo, undo []core.Event) error) error

Open opens and replays IntentLogger.Filename.

For each intent-entry, it searches for a completion marker. For all entries with no corresponding completion marker, it calls the provided IncompleteTransactionHandler with the redo / undo []byte content provided to the original intent-entry. After calling the handler, and if the handler did not return an error, it writes a new completion-marker to the log to prevent the same entry from being handled if IntentLogger.Open() is called multiple times on the same logfile.

func (IntentLogger) WriteIntent

func (il IntentLogger) WriteIntent(redo, undo []core.Event) (uuid.UUID, error)

WriteIntent writes the given redo/undo content to the log, and returns an ID for that entry which must later be passed to ConfirmIntentCompletion() to mark the entry as completed.

type ToDomainer

type ToDomainer interface {
	ToDomain() core.Event
	SetHeader(eventHeader)
}

Jump to

Keyboard shortcuts

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