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 ¶
- func NewStandalone(port int, proxyName, zoneName string) (func(poller.Consumer) Differ, poller.Registrar)
- type Diff
- func DiffAndPatch(d Differ, proposed []api.Cluster, opts DiffOpts) ([]Diff, error)
- func NewDiffAddInstance(clusterKey api.ClusterKey, checksum api.Checksum, instance api.Instance) Diff
- func NewDiffCreate(cluster api.Cluster) Diff
- func NewDiffDelete(clusterKey api.ClusterKey, checksum api.Checksum) Diff
- func NewDiffModify(cluster api.Cluster) Diff
- func NewDiffRemoveInstance(clusterKey api.ClusterKey, checksum api.Checksum, instance api.Instance) Diff
- type DiffOpts
- type Differ
- type MockDiffer
- type MockDifferMockRecorder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 ¶
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 ¶
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.
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.
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 ¶
Diff mocks base method
func (*MockDiffer) EXPECT ¶
func (m *MockDiffer) EXPECT() *MockDifferMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
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