differ

package
v0.0.0-...-1fc1f69 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package differ implements a mechanism for synchronization of the local service discovery regime to the Turbine Labs public API.

The Differ mirrors the data from an existing service discovery regime into the Cluster service using the customer site as the source of truth. This should ideally involve a combination of full-Zone reconciliation and incremental patching of Diffs. Since these involve large-scale comparison of the two datasets, it's probably more important to make sure multiple agents either don't operate at the same time, or can operate safely concurrently.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStandalone

func NewStandalone(
	port int,
	proxyName,
	zoneName string,
) (func(poller.Consumer) Differ, poller.Registrar)

NewStandalone produces a function that will create a Differ from a poller.Consumer, and a Registrar suitable for injection into an xDS.

Types

type Diff

type Diff interface {
	// Checksum returns the current checksum of the Cluster to be modified
	Checksum() api.Checksum
	// ClusterKey returns the ClusterKey of the Cluster to be modified
	ClusterKey() api.ClusterKey
	// Patch applies the modification to the given Cluster service,
	// using the given checksum, returing a new Diff with a potentially
	// different Checksum or ClusterKey.
	Patch(svc service.Cluster, checksum api.Checksum) (Diff, error)
	// Produce a map suitable for serialization
	DisplayMap() map[string]interface{}
}

Diff models a Cluster modification to be applied

func DiffAndPatch

func DiffAndPatch(
	d Differ,
	proposed []api.Cluster,
	opts DiffOpts,
) ([]Diff, error)

DiffAndPatch uses the given Differ to add, modify, and remove Clusters in a given ZoneKey to match the given slice of Clusters. The slice of Diffs applied is returned.

func NewDiffAddInstance

func NewDiffAddInstance(
	clusterKey api.ClusterKey,
	checksum api.Checksum,
	instance api.Instance,
) Diff

NewDiffAddInstance creates a Diff representing adding the given Instance to the Cluster corresponding to the given ClusterKey. The given Cluster Checksum must match the existing Checksum.

func NewDiffCreate

func NewDiffCreate(cluster api.Cluster) Diff

NewDiffCreate creates a Diff representing creation of a Cluster

func NewDiffDelete

func NewDiffDelete(clusterKey api.ClusterKey, checksum api.Checksum) Diff

NewDiffDelete creates a Diff representing deletion of a Cluster corresponding to the given ClusterKey. The given Cluster Checksum must match the existing Checksum.

func NewDiffModify

func NewDiffModify(cluster api.Cluster) Diff

NewDiffModify creates a Diff representing modification of a Cluster. The given Cluster Checksum must match the existing Checksum.

func NewDiffRemoveInstance

func NewDiffRemoveInstance(
	clusterKey api.ClusterKey,
	checksum api.Checksum,
	instance api.Instance,
) Diff

NewDiffRemoveInstance creates a Diff representing removing the given Instance to the Cluster corresponding to the given ClusterKey. The given Cluster Checksum must match the existing Checksum.

type DiffOpts

type DiffOpts struct {
	IgnoreCreate  bool // If true, don't include cluster creation in the []Diff
	IncludeDelete bool // If true, include cluster deletion in the []Diff
	DryRun        bool // If true, don't apply destructive operations
}

DiffOpts describe desired behavior when producing a []Diff of two clusters.

func DiffOptsFromFlags

func DiffOptsFromFlags(flagset tbnflag.FlagSet) *DiffOpts

DiffOptsFromFlags install flags necessary to configure a DiffOpts into the provided FlagSet. Returns a pointer to the configured DiffOpts.

type Differ

type Differ interface {
	// Diff returns a slice of Diffs representing the changes necessary to make
	// the Clusters in the Cluster service match the proposed slice of Clusters.
	Diff(proposed []api.Cluster, opts DiffOpts) ([]Diff, error)

	// Patch will apply a slice of Diffs to the Cluster service.
	Patch(diffs []Diff) error
}

Differ allows diffing and patching between the current Clusters and a proposed slice.

func New

func New(svc service.Cluster, zoneKey api.ZoneKey) Differ

New returns a Differ backed by the given service.Cluster.

type MockDiffer

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

MockDiffer is a mock of Differ interface

func NewMockDiffer

func NewMockDiffer(ctrl *gomock.Controller) *MockDiffer

NewMockDiffer creates a new mock instance

func (*MockDiffer) Diff

func (m *MockDiffer) Diff(proposed []api.Cluster, opts DiffOpts) ([]Diff, error)

Diff mocks base method

func (*MockDiffer) EXPECT

func (m *MockDiffer) EXPECT() *MockDifferMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockDiffer) Patch

func (m *MockDiffer) Patch(diffs []Diff) error

Patch mocks base method

type MockDifferMockRecorder

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

MockDifferMockRecorder is the mock recorder for MockDiffer

func (*MockDifferMockRecorder) Diff

func (mr *MockDifferMockRecorder) Diff(proposed, opts interface{}) *gomock.Call

Diff indicates an expected call of Diff

func (*MockDifferMockRecorder) Patch

func (mr *MockDifferMockRecorder) Patch(diffs interface{}) *gomock.Call

Patch indicates an expected call of Patch

Source Files

  • diff.go
  • diff_opts.go
  • differ.go
  • mock_differ.go
  • standalone.go

Jump to

Keyboard shortcuts

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