core

package
v1.7.6-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init() error

Init creates the GlobalController and inits it

Types

type Controller

type Controller interface {
	policy.Manager
	Init() error
	Replicate(policyID int64, metadata ...map[string]interface{}) error
}

Controller defines the methods that a replicatoin controllter should implement

var (
	GlobalController Controller
)

Keep controller as singleton instance

type ControllerConfig

type ControllerConfig struct {
	// The capacity of the cache storing enabled triggers
	CacheCapacity int
}

ControllerConfig includes related configurations required by the controller

type DefaultController

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

DefaultController is core module to cordinate and control the overall workflow of the replication modules.

func NewDefaultController

func NewDefaultController(cfg ControllerConfig) *DefaultController

NewDefaultController is the constructor of DefaultController.

func (*DefaultController) CreatePolicy

func (ctl *DefaultController) CreatePolicy(newPolicy models.ReplicationPolicy) (int64, error)

CreatePolicy is used to create a new policy and enable it if necessary

func (*DefaultController) GetPolicies

GetPolicies is delegation of GetPoliciemodels.ReplicationPolicy{}s of Policy.Manager

func (*DefaultController) GetPolicy

func (ctl *DefaultController) GetPolicy(policyID int64) (models.ReplicationPolicy, error)

GetPolicy is delegation of GetPolicy of Policy.Manager

func (*DefaultController) Init

func (ctl *DefaultController) Init() error

Init will initialize the controller and the sub components

func (*DefaultController) RemovePolicy

func (ctl *DefaultController) RemovePolicy(policyID int64) error

RemovePolicy will remove the specified policy and clean the related settings

func (*DefaultController) Replicate

func (ctl *DefaultController) Replicate(policyID int64, metadata ...map[string]interface{}) error

Replicate starts one replication defined in the specified policy; Can be launched by the API layer and related triggers.

func (*DefaultController) UpdatePolicy

func (ctl *DefaultController) UpdatePolicy(updatedPolicy models.ReplicationPolicy) error

UpdatePolicy will update the policy with new content. Parameter updatedPolicy must have the ID of the updated policy.

Jump to

Keyboard shortcuts

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