client

package
v0.0.0-...-ba1c585 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2017 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package client defines an interface that syncbase clients must implement. Each syncbase instance in a longevity test will have an associated client that interacts with it. The clients' behavior should reflect real-world use cases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDbsAndCollections

func CreateDbsAndCollections(ctx *context.T, sbName string, dbModels model.DatabaseSet) (map[syncbase.Database][]syncbase.Collection, []syncbase.Syncgroup, error)

CreateDbsAndCollections creates databases and collections according to the given models. It does not fail if any of the databases or collections already exist. If the model contains syncgroups, it will also create or join those as well.

Types

type Client

type Client interface {
	// String returns a string representation of the client, suitable for
	// printing.
	String() string

	// Start starts the client, which will perform operations on databases
	// corresponding to the given models.  Start must not block.  It is the
	// implementation's responsibility to guarantee that the databases and
	// their collections exist.
	// TODO(nlacasse): Should implementation panic on non-recoverable errors?
	Start(ctx *context.T, sbName string, dbs model.DatabaseSet)

	// Stop stops the client and waits for it to exit.
	Stop() error
}

Client represents a syncbase client in a longevity test.

type Noop

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

Noop is a client that creates any databases, collections, and syncgroups in the model, and then does nothing.

func (*Noop) Start

func (noop *Noop) Start(ctx *context.T, sbName string, dbModels model.DatabaseSet)

func (*Noop) Stop

func (noop *Noop) Stop() error

func (*Noop) String

func (noop *Noop) String() string

type Watcher

type Watcher struct {
	// Prefix to watch.  Defaults to empty string.
	// TODO(nlacasse): Allow different prefixes per collection?
	Prefix string

	// ResumeMarker to begin watching from.
	// TODO(nlacasse): Allow different ResumeMarkers per collection?
	ResumeMarker watch.ResumeMarker

	// OnChange runs for each WatchChange.  Must be goroutine-safe.  By default
	// this will be a no-op.
	OnChange func(syncbase.WatchChange)
	// contains filtered or unexported fields
}

Watcher is a client that watches a range of keys in a set of database collections.

func (*Watcher) Start

func (w *Watcher) Start(ctx *context.T, sbName string, dbModels model.DatabaseSet)

func (*Watcher) Stop

func (w *Watcher) Stop() error

func (*Watcher) String

func (w *Watcher) String() string

type Writer

type Writer struct {
	// Amount of time to wait between db writes.  Defaults to 1 second.
	WriteInterval time.Duration

	// Function that generates successive key/value pairs.  If key is "", no
	// row will be written.
	// If KeyValueFunc is nil, keys will be strings containing the current unix
	// timestamp and values will be random hex strings.
	KeyValueFunc func(time.Time) (string, interface{})

	// Function that will run after each write with the collection, key, value,
	// and an error if one was encountered.  Useful for tests.
	OnWrite func(syncbase.Collection, string, interface{}, error)
	// contains filtered or unexported fields
}

Writer is a Client that periodically writes key/value pairs to a set of collections in a database. The time between writes can be configured by setting WriteInterval. The key/value pairs can be configured by setting KeyValueFunc.

func (*Writer) Start

func (w *Writer) Start(ctx *context.T, sbName string, databases model.DatabaseSet)

func (*Writer) Stop

func (w *Writer) Stop() error

func (*Writer) String

func (w *Writer) String() string

Jump to

Keyboard shortcuts

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