replicator

package module
v0.0.0-...-c5b7652 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

replicator Go Reference

Go implementation of https://docs.couchdb.org/en/stable/replication/protocol.html

Goal is to have a 100% compatible implemntation of the replicator.

Ideas

Create a kubernetes deployable replicator. Requirements:

  • Configuration via environment
  • Chart example
  • Docker container
  • Logging
  • Termination log

Couchdb

Launch via podman for local testing.

make couchdb

Documentation

Index

Constants

View Source
const MB10 = 10 * (1024 ^ 2)

MB10 10 MB

View Source
const NoVersion = "0"

Variables

View Source
var (
	ErrAbort                = errors.New("abort replication")
	ErrReplicationCompleted = errors.New("replication completed")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Heartbeat For Continuous Replication the heartbeat parameter defines the heartbeat period in milliseconds. The RECOMMENDED value by default is 10000 (10 seconds).
	Heartbeat time.Duration
}

func (Config) HeartbeatOrFallback

func (c Config) HeartbeatOrFallback() time.Duration

type Job

type Job struct {
	ID           string         `json:"_id"`
	Rev          string         `json:"_rev"`
	UserCtx      UserCtx        `json:"user_ctx"`
	Source       *client.Remote `json:"source"`
	Target       *client.Remote `json:"target"`
	CreateTarget bool           `json:"create_target"`
	Continuous   bool           `json:"continuous"`
	Owner        string         `json:"owner"`

	Config
}

func (*Job) GenerateReplicationID

func (j *Job) GenerateReplicationID(name string) string

GenerateReplicationID generates a replication id using the given name, name could be a hostame. https://docs.couchdb.org/en/stable/replication/protocol.html#generate-replication-id

type Replicator

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

Replicator implements the couchdb replication protocol: https://docs.couchdb.org/en/stable/replication/protocol.html

func NewReplicator

func NewReplicator(name string, job *Job) (*Replicator, error)

func (*Replicator) CompareReplicationLogs

func (r *Replicator) CompareReplicationLogs(ctx context.Context, source, target *client.ReplicationLog) error

2.4.2.3.3. Compare Replication Logs

func (*Replicator) Reset

func (r *Replicator) Reset(ctx context.Context) error

Reset resets the replicator state at the source and target database

func (*Replicator) Run

func (r *Replicator) Run(ctx context.Context) error

func (*Replicator) SetLogger

func (r *Replicator) SetLogger(logger logger.Logger)

type UserCtx

type UserCtx struct {
	Name  string   `json:"name"`
	Roles []string `json:"roles"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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