go-core: github.com/stratumn/go-core/fossilizer Index | Files | Directories

package fossilizer

import "github.com/stratumn/go-core/fossilizer"

Package fossilizer defines types to implement a fossilizer.


Package Files

exporter.go fossilizer.go queue.go

func RunExporter Uses

func RunExporter(ctx context.Context, f Adapter, e EventExporter)

RunExporter connects the given exporter to the given fossilizer. RunExporter should run inside a go routine and will return when the context is cancelled.

type Adapter Uses

type Adapter interface {
    // Returns arbitrary information about the adapter.
    GetInfo(context.Context) (interface{}, error)

    // Adds a channel that receives events from the fossilizer
    AddFossilizerEventChan(chan *Event)

    // Requests data to be fossilized.
    // Meta is arbitrary data that will be forwarded to the websocket.
    Fossilize(ctx context.Context, data []byte, meta []byte) error

Adapter must be implemented by a fossilier.

type Event Uses

type Event struct {
    EventType EventType
    Data      interface{}

Event is the object fossilizers send to notify of important events.

func (Event) Result Uses

func (e Event) Result() (*Result, error)

Result converts the event data to a fossilizer.Result.

type EventExporter Uses

type EventExporter interface {
    // Push an event to the exporter.
    Push(context.Context, *Event) error

EventExporter can be used to export events generated by a fossilizer.

type EventType Uses

type EventType string

EventType lets you know the kind of event received. A client should ignore events it doesn't care about or doesn't understand.

const (
    // DidFossilize is sent when a piece of data was successfully fossilized.
    DidFossilize EventType = "DidFossilize"

type Fossil Uses

type Fossil struct {
    // The data that was fossilized.
    Data []byte `json:"data"`

    // The metadata associated with the fossilized data.
    Meta []byte `json:"meta"`

Fossil that will be fossilized.

type FossilsQueue Uses

type FossilsQueue interface {
    // Push a fossil to the queue.
    Push(context.Context, *Fossil) error

    // Pop fossils from the queue.
    Pop(context.Context, int) ([]*Fossil, error)

FossilsQueue can be used by batch fossilizers to store data that's pending fossilization. StorageQueue implementations can use persistent storage (like cloud queues) to prevent loss of data in cloud micro-services architecture.

type Result Uses

type Result struct {
    // Evidence created by the fossilizer.
    Evidence chainscript.Evidence

    // The fossilized data.

Result is the type sent to the result channels.


fossilizerhttpPackage fossilizerhttp is used to create an HTTP server from a fossilizer adapter.
fossilizertestingPackage fossilizertesting defines helpers to test fossilizers.

Package fossilizer imports 4 packages (graph) and is imported by 28 packages. Updated 2019-02-27. Refresh now. Tools for package owners.