livesync

package
v0.0.0-...-6d02989 Latest Latest
Warning

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

Go to latest
Published: May 24, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPagination = 50

DefaultPagination is the number of links fetched by API call.

View Source
const DefaultPollInterval = 10000

DefaultPollInterval is the default interval at which the livesync service calls Startumn APIs (in milliseconds).

Variables

View Source
var (
	// ErrNotClient is returned when the connected service is not a stratumn client.
	ErrNotClient = errors.New("connected service is not a stratumn client")
)

Functions

func CompareCursors

func CompareCursors(cursor1, cursor2 string) (int, error)

CompareCursors returns the difference between relay cursors. Relay cursors are base64 encoded strings that look like this: ["natural",109]. The second element of the slice is the incrementing index, this is what we want to compare.

Types

type Config

type Config struct {
	// ConfigVersion is the version of the configuration file.
	ConfigVersion int `toml:"configuration_version" comment:"The version of the service configuration."`

	PollInterval     time.Duration `toml:"poll_interval" comment:"The frenquency (in milliseconds) at which the livesync service polls data from Stratumn APIs."`
	WatchedWorkflows []string      `toml:"watched_workflows" comment:"The IDs of the workflows to synchronize data from."`
}

Config contains configuration options for the Livesync service.

type Service

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

Service is the Livesync service.

func (*Service) Config

func (s *Service) Config() interface{}

Config returns the current service configuration or creates one with good default values.

func (*Service) Desc

func (s *Service) Desc() string

Desc returns a description of what the service does.

func (*Service) Expose

func (s *Service) Expose() interface{}

Expose exposes the synchronizer client to other services. It exposes the Synchronizer instance.

func (*Service) ID

func (s *Service) ID() string

ID returns the unique identifier of the service.

func (*Service) Migrations

func (s *Service) Migrations() []cfg.MigrateHandler

Migrations is the services migrations.

func (*Service) Name

func (s *Service) Name() string

Name returns the human friendly name of the service.

func (*Service) Needs

func (s *Service) Needs() map[string]struct{}

Needs returns the set of services this service depends on.

func (*Service) Plug

func (s *Service) Plug(exposed map[string]interface{}) error

Plug sets the connected services.

func (*Service) Run

func (s *Service) Run(ctx context.Context, running, stopping func()) error

Run starts the service.

func (*Service) SetConfig

func (s *Service) SetConfig(config interface{}) error

SetConfig configures the service.

func (*Service) VersionKey

func (s *Service) VersionKey() string

VersionKey is the version key.

type Synchronizer

type Synchronizer interface {
	Register(WorkflowStates) (<-chan []*cs.Segment, error)
}

Synchronizer is the type exposed by the livesync service.

func NewSycnhronizer

func NewSycnhronizer(client client.StratumnClient, watchedWorkflows []string) Synchronizer

NewSycnhronizer returns a new Synchronizer. It takes a stratumn client and a list of workflows to sync with.

type WorkflowState

type WorkflowState struct {
	ID     string
	Cursor string
}

WorkflowState maps the ID of the workflow to the cursor of the last synced link.

type WorkflowStates

type WorkflowStates []*WorkflowState

WorkflowStates is a list of WorkflowState

func (WorkflowStates) Get

func (wfStates WorkflowStates) Get(id string) (*WorkflowState, bool)

Get finds a WorkflowState in the list given its ID.

Directories

Path Synopsis
Package mocksynchronizer is a generated GoMock package.
Package mocksynchronizer is a generated GoMock package.

Jump to

Keyboard shortcuts

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