container

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 9 Imported by: 9

Documentation

Overview

A collection of models. Provides methods to reconcile the collection of stored models with the collection of desired models.

Container

|__Collector
|__Collector
|__Collector

The container is a collection of data model collectors. Each collector is responsible for ensuring that changes made to the external data source are reflected in the DB. The goal is for the data model to be eventually consistent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection added in v0.4.3

type Collection struct {
	// Stored models.
	Stored fb.Iterator
	// DB transaction.
	Tx *model.Tx
	// An (optional) shepherd.
	Shepherd Shepherd
	// Number of models added.
	Added int
	// Number models updated.
	Updated int
	// Number models deleted.
	Deleted int
}

Model collection.

func (*Collection) Add added in v0.4.3

func (r *Collection) Add(desired fb.Iterator) error

Add models included in desired but not stored.

func (*Collection) Delete added in v0.4.3

func (r *Collection) Delete(desired fb.Iterator) error

Delete stored models not included in the desired.

func (*Collection) Reconcile added in v0.4.3

func (r *Collection) Reconcile(desired fb.Iterator) (err error)

Reconcile the collection. Ensure the stored collection is as desired.

func (*Collection) Update added in v0.4.3

func (r *Collection) Update(desired fb.Iterator) error

Update models.

type Collector added in v0.6.0

type Collector interface {
	// The name.
	Name() string
	// The resource that owns the collector.
	Owner() meta.Object
	// Start the collector.
	// Expected to do basic validation, start a
	// goroutine and return quickly.
	Start() error
	// Shutdown the collector.
	// Expected to disconnect, destroy created resources
	// and return quickly.
	Shutdown()
	// The collector has achieved parity.
	HasParity() bool
	// Get the associated DB.
	DB() model.DB
	// Test connection with credentials.
	Test() error
	// Reset
	Reset()
}

Data collector.

type Container

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

A container manages a collection of `Collector`.

func New

func New() *Container

Build a new container.

func (*Container) Add

func (c *Container) Add(collector Collector) (err error)

Add a collector.

func (*Container) Delete

func (c *Container) Delete(owner meta.Object) (p Collector, found bool)

Delete the collector.

func (*Container) Get

func (c *Container) Get(owner meta.Object) (Collector, bool)

Get a collector by (CR) object.

func (*Container) List

func (c *Container) List() []Collector

List all collectors.

func (*Container) Replace

func (c *Container) Replace(collector Collector) (p Collector, found bool, err error)

Replace a collector.

type DefaultShepherd added in v0.4.3

type DefaultShepherd struct {
}

Default (reflect-based) shepherd. Fields are ignored when:

  • Is the PK.
  • Is (auto) incremented.
  • Has the `eq:"-"` tag.

func (*DefaultShepherd) Equals added in v0.4.3

func (r *DefaultShepherd) Equals(mA, mB model.Model) bool

Model comparison.

func (*DefaultShepherd) Update added in v0.4.3

func (r *DefaultShepherd) Update(mA, mB model.Model)

Update model A (stored) with model B (desired).

type Disposition added in v0.4.3

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

Disposition.

type Dispositions added in v0.4.3

type Dispositions map[string]*Disposition

Disposition map.

type Key

Collector key.

type Shepherd added in v0.4.3

type Shepherd interface {
	// Determine if model needs to be updated.
	Equals(mA, mB model.Model) bool
	// Update the stored model as desired.
	Update(stored, desired model.Model)
}

Model shepherd.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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