client

package
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: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
	ErrFailed   = errors.New("operation failed")
)

Functions

This section is empty.

Types

type ChangeOptions

type ChangeOptions struct {
	Heartbeat time.Duration
	Since     string
}

type Changes

type Changes struct {
	Rev string `json:"rev"`
}

type ChangesResponse

type ChangesResponse struct {
	Results []Results `json:"results"`
	LastSeq string    `json:"last_seq"`
}

type Client

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

func NewClient

func NewClient(r *Remote) (*Client, error)

func (*Client) BulkDocs

func (c *Client) BulkDocs(ctx context.Context, stack *Stack) error

BulkDocs 2.4.2.5.2. Upload Batch of Changed Documents

func (*Client) Changes

func (c *Client) Changes(ctx context.Context, opts ChangeOptions) (*ChangesResponse, error)

func (*Client) Check

func (c *Client) Check(ctx context.Context) error

func (*Client) Create

func (c *Client) Create(ctx context.Context) error

func (*Client) EnsureFullCommit

func (c *Client) EnsureFullCommit(ctx context.Context) error

EnsureFullCommit 2.4.2.5.4. Ensure In Commit

func (*Client) GetDocumentComplete

func (c *Client) GetDocumentComplete(ctx context.Context, docid string, diff *Diff) (*CompleteDoc, error)

GetDocumentComplete 2.4.2.5.1. Fetch Changed Documents

func (*Client) GetReplicationLog

func (c *Client) GetReplicationLog(ctx context.Context, id string) (*ReplicationLog, error)

func (*Client) Info

func (c *Client) Info(ctx context.Context) (*Info, error)

func (*Client) RecordReplicationCheckpoint

func (c *Client) RecordReplicationCheckpoint(ctx context.Context, repLog *ReplicationLog, replicationID string) error

RecordReplicationCheckpoint 2.4.2.5.5. Record Replication Checkpoint

func (*Client) RemoveReplicationCheckpoint

func (c *Client) RemoveReplicationCheckpoint(ctx context.Context, replicationID string) error

func (*Client) RevDiff

func (c *Client) RevDiff(ctx context.Context, r RevDiffRequest) (DiffResponse, error)

func (*Client) SetLogger

func (c *Client) SetLogger(logger logger.Logger)

func (*Client) UploadDocumentWithAttachments

func (c *Client) UploadDocumentWithAttachments(ctx context.Context, doc *CompleteDoc) error

UploadDocumentWithAttachments 2.4.2.5.3. Upload Document with Attachments

type CompleteDoc

type CompleteDoc struct {
	ID   string
	Data map[string]interface{}
	// contains filtered or unexported fields
}

func NewCompleteDoc

func NewCompleteDoc(docid string, resp *http.Response) (*CompleteDoc, error)

func (*CompleteDoc) Close

func (d *CompleteDoc) Close() error

func (*CompleteDoc) HasChangedAttachments

func (d *CompleteDoc) HasChangedAttachments() bool

func (*CompleteDoc) InlineAttachments

func (d *CompleteDoc) InlineAttachments() error

InlineAttachments inline the attachments using the base64 encoding.

func (*CompleteDoc) Reader

func (d *CompleteDoc) Reader() (io.ReadCloser, string, error)

Reader returns a multipart mime representation of the complete doc

func (*CompleteDoc) Size

func (d *CompleteDoc) Size() int64

type Diff

type Diff struct {
	// Missing contains missing revisions
	Missing []string `json:"missing"`
}

type DiffResponse

type DiffResponse map[string]*Diff

type History

type History struct {
	DocWriteFailures int    `json:"doc_write_failures"` // Number of failed writes
	DocsRead         int    `json:"docs_read"`          // Number of read documents
	DocsWritten      int    `json:"docs_written"`       // Number of written documents
	EndLastSeq       string `json:"end_last_seq"`       // Last processed Update Sequence ID
	EndTime          Time   `json:"end_time"`           // Replication completion timestamp in RFC 5322 format
	MissingChecked   int    `json:"missing_checked"`    // Number of checked revisions on Source
	MissingFound     int    `json:"missing_found"`      // Number of missing revisions found on Target
	RecordedSeq      string `json:"recorded_seq"`       // Recorded intermediate Checkpoint. Required
	SessionID        string `json:"session_id"`         // Unique session ID. Commonly, a random UUID value is used. Required
	StartLastSeq     string `json:"start_last_seq"`     // Start update Sequence ID
	StartTime        Time   `json:"start_time"`         // Replication start timestamp in RFC 5322 format
}

type Info

type Info struct {
	CommittedUpdateSeq int    `json:"committed_update_seq"`
	CompactRunning     bool   `json:"compact_running"`
	DbName             string `json:"db_name"`
	DiskFormatVersion  int    `json:"disk_format_version"`
	DocCount           int    `json:"doc_count"`
	DocDelCount        int    `json:"doc_del_count"`
	InstanceStartTime  string `json:"instance_start_time"`
	PurgeSeq           string `json:"purge_seq"`
	Sizes              Sizes  `json:"sizes"`
	UpdateSeq          string `json:"update_seq"`
}

type Remote

type Remote struct {
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers"`
}

func (Remote) GenerateReplicationID

func (r Remote) GenerateReplicationID(b *bufio.Writer)

type ReplicationLog

type ReplicationLog struct {
	ID                   string     `json:"_id"`
	Rev                  string     `json:"_rev,omitempty"`
	History              []*History `json:"history"`
	ReplicationIDVersion int        `json:"replication_id_version"` // Replication protocol version. Defines Replication ID calculation algorithm, HTTP API calls and the others routines. Required
	SessionID            string     `json:"session_id"`             // Unique ID of the last session. Shortcut to the session_id field of the latest history object. Required
	SourceLastSeq        string     `json:"source_last_seq"`        // Last processed Checkpoint. Shortcut to the recorded_seq field of the latest history object. Required
}

type Results

type Results struct {
	Seq     string    `json:"seq"`
	ID      string    `json:"id"`
	Changes []Changes `json:"changes"`
	Deleted bool      `json:"deleted,omitempty"`
}

type RevDiffRequest

type RevDiffRequest map[string][]string

type Sizes

type Sizes struct {
	Active   int64 `json:"active"`
	Disk     int64 `json:"disk"`
	External int64 `json:"external"`
}

type Stack

type Stack []*CompleteDoc

func (Stack) Reader

func (s Stack) Reader() (io.ReadCloser, error)

Reader generates a reader that serializes the stacks data to json

func (Stack) Size

func (s Stack) Size() int64

Size returns the total size of all the documents in the stack in bytes

type Time

type Time time.Time

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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