Documentation ¶
Index ¶
- Constants
- Variables
- func CopyConfigFile(c *common.ConfigFile) *common.ConfigFile
- func CopyConfigFileMeta(c *common.ConfigFileMeta) *common.ConfigFileMeta
- func CopyConfigFileSpec(c *common.ConfigFileSpec) *common.ConfigFileSpec
- func CopyConfigs(c1 []common.ConfigID) []common.ConfigID
- func CopyDevice(d *common.Device) *common.Device
- func CopyMemberMeta(m *common.MemberMeta) *common.MemberMeta
- func CopyMemberSpec(m *common.MemberSpec) *common.MemberSpec
- func CopyMemberVolumes(v *common.MemberVolumes) *common.MemberVolumes
- func CopyResources(r *common.Resources) *common.Resources
- func CopyService(s *common.Service) *common.Service
- func CopyServiceAttr(s *common.ServiceAttr) *common.ServiceAttr
- func CopyServiceMember(m *common.ServiceMember) *common.ServiceMember
- func CopyServiceMeta(s *common.ServiceMeta) *common.ServiceMeta
- func CopyServiceSpec(s *common.ServiceSpec) *common.ServiceSpec
- func CopyServiceStaticIP(s *common.ServiceStaticIP) *common.ServiceStaticIP
- func CopyServiceVolume(v *common.ServiceVolume) *common.ServiceVolume
- func CopyServiceVolumes(v *common.ServiceVolumes) *common.ServiceVolumes
- func CopyStaticIPSpec(s *common.StaticIPSpec) *common.StaticIPSpec
- func CreateConfigFile(serviceUUID string, fileID string, revision int64, meta *common.ConfigFileMeta, ...) *common.ConfigFile
- func CreateConfigFileMeta(fileName string, mtime int64) *common.ConfigFileMeta
- func CreateConfigFileSpec(fileMode uint32, fileMD5 string, content string) *common.ConfigFileSpec
- func CreateDevice(cluster string, device string, service string) *common.Device
- func CreateInitialConfigFile(serviceUUID string, fileID string, fileName string, fileMode uint32, ...) *common.ConfigFile
- func CreateInitialMemberSpec(az string, vols *common.MemberVolumes, staticIP string, ...) *common.MemberSpec
- func CreateMemberMeta(mtime int64, status string) *common.MemberMeta
- func CreateMemberSpec(az string, taskID string, containerInstanceID string, serverInstanceID string, ...) *common.MemberSpec
- func CreateNewConfigFile(c *common.ConfigFile, newFileID string, newContent string) *common.ConfigFile
- func CreateService(cluster string, service string, serviceUUID string) *common.Service
- func CreateServiceAttr(serviceUUID string, revision int64, meta *common.ServiceMeta, ...) *common.ServiceAttr
- func CreateServiceMember(serviceUUID string, memberName string, revision int64, meta *common.MemberMeta, ...) *common.ServiceMember
- func CreateServiceMeta(cluster string, service string, mtime int64, serviceType string, status string) *common.ServiceMeta
- func CreateServiceSpec(replicas int64, res *common.Resources, registerDNS bool, domain string, ...) *common.ServiceSpec
- func CreateServiceStaticIP(staticIP string, revision int64, spec *common.StaticIPSpec) *common.ServiceStaticIP
- func CreateStaticIPSpec(serviceUUID string, az string, serverInstanceID string, netInterfaceID string) *common.StaticIPSpec
- func EqualConfigFile(c1 *common.ConfigFile, c2 *common.ConfigFile, skipMtime bool, skipContent bool) bool
- func EqualConfigs(c1 []common.ConfigID, c2 []common.ConfigID) bool
- func EqualDevice(t1 *common.Device, t2 *common.Device) bool
- func EqualMemberMeta(m1 *common.MemberMeta, m2 *common.MemberMeta, skipMtime bool) bool
- func EqualMemberSpec(m1 *common.MemberSpec, m2 *common.MemberSpec) bool
- func EqualMemberVolumes(v1 *common.MemberVolumes, v2 *common.MemberVolumes) bool
- func EqualResources(r1 *common.Resources, r2 *common.Resources) bool
- func EqualService(t1 *common.Service, t2 *common.Service) bool
- func EqualServiceAttr(s1 *common.ServiceAttr, s2 *common.ServiceAttr, skipMtime bool, ...) bool
- func EqualServiceAttrImmutableFields(s1 *common.ServiceAttr, s2 *common.ServiceAttr) bool
- func EqualServiceMember(t1 *common.ServiceMember, t2 *common.ServiceMember, skipMtime bool) bool
- func EqualServiceMemberImmutableFields(m1 *common.ServiceMember, m2 *common.ServiceMember) bool
- func EqualServiceMeta(s1 *common.ServiceMeta, s2 *common.ServiceMeta, skipMtime bool) bool
- func EqualServiceSpec(s1 *common.ServiceSpec, s2 *common.ServiceSpec) bool
- func EqualServiceStaticIP(t1 *common.ServiceStaticIP, t2 *common.ServiceStaticIP) bool
- func EqualServiceStaticIPImmutableFields(t1 *common.ServiceStaticIP, t2 *common.ServiceStaticIP) bool
- func EqualServiceVolume(v1 *common.ServiceVolume, v2 *common.ServiceVolume) bool
- func EqualServiceVolumes(v1 *common.ServiceVolumes, v2 *common.ServiceVolumes) bool
- func EqualStaticIPSpec(t1 *common.StaticIPSpec, t2 *common.StaticIPSpec) bool
- func PrintConfigFile(cfg *common.ConfigFile) string
- func UpdateServiceConfig(s *common.ServiceAttr, cfgIndex int, newFileID string, fileMD5 string) *common.ServiceAttr
- func UpdateServiceMemberConfigs(t1 *common.ServiceMember, c []common.ConfigID) *common.ServiceMember
- func UpdateServiceMemberOwner(t1 *common.ServiceMember, taskID string, containerInstanceID string, ...) *common.ServiceMember
- func UpdateServiceReplicas(s *common.ServiceAttr, replicas int64) *common.ServiceAttr
- func UpdateServiceResources(s *common.ServiceAttr, res *common.Resources) *common.ServiceAttr
- func UpdateServiceStaticIP(t1 *common.ServiceStaticIP, serverInstanceID string, netInterfaceID string) *common.ServiceStaticIP
- func UpdateServiceStatus(s *common.ServiceAttr, status string) *common.ServiceAttr
- type DB
- type MemDB
- func (d *MemDB) CreateConfigFile(ctx context.Context, cfg *common.ConfigFile) error
- func (d *MemDB) CreateDevice(ctx context.Context, dev *common.Device) error
- func (d *MemDB) CreateService(ctx context.Context, svc *common.Service) error
- func (d *MemDB) CreateServiceAttr(ctx context.Context, attr *common.ServiceAttr) error
- func (d *MemDB) CreateServiceMember(ctx context.Context, member *common.ServiceMember) error
- func (d *MemDB) CreateServiceStaticIP(ctx context.Context, serviceip *common.ServiceStaticIP) error
- func (d *MemDB) CreateSystemTables(ctx context.Context) error
- func (d *MemDB) DeleteConfigFile(ctx context.Context, serviceUUID string, fileID string) error
- func (d *MemDB) DeleteDevice(ctx context.Context, clusterName string, deviceName string) error
- func (d *MemDB) DeleteService(ctx context.Context, clusterName string, serviceName string) error
- func (d *MemDB) DeleteServiceAttr(ctx context.Context, serviceUUID string) error
- func (d *MemDB) DeleteServiceMember(ctx context.Context, serviceUUID string, memberName string) error
- func (d *MemDB) DeleteServiceStaticIP(ctx context.Context, ip string) error
- func (d *MemDB) DeleteSystemTables(ctx context.Context) error
- func (d *MemDB) GetConfigFile(ctx context.Context, serviceUUID string, fileID string) (cfg *common.ConfigFile, err error)
- func (d *MemDB) GetDevice(ctx context.Context, clusterName string, deviceName string) (dev *common.Device, err error)
- func (d *MemDB) GetService(ctx context.Context, clusterName string, serviceName string) (svc *common.Service, err error)
- func (d *MemDB) GetServiceAttr(ctx context.Context, serviceUUID string) (attr *common.ServiceAttr, err error)
- func (d *MemDB) GetServiceMember(ctx context.Context, serviceUUID string, memberName string) (member *common.ServiceMember, err error)
- func (d *MemDB) GetServiceStaticIP(ctx context.Context, ip string) (serviceip *common.ServiceStaticIP, err error)
- func (d *MemDB) ListDevices(ctx context.Context, clusterName string) (devs []*common.Device, err error)
- func (d *MemDB) ListServiceMembers(ctx context.Context, serviceUUID string) (members []*common.ServiceMember, err error)
- func (d *MemDB) ListServices(ctx context.Context, clusterName string) (svcs []*common.Service, err error)
- func (d *MemDB) SystemTablesReady(ctx context.Context) (tableStatus string, ready bool, err error)
- func (d *MemDB) UpdateServiceAttr(ctx context.Context, oldAttr *common.ServiceAttr, newAttr *common.ServiceAttr) error
- func (d *MemDB) UpdateServiceMember(ctx context.Context, oldMember *common.ServiceMember, ...) error
- func (d *MemDB) UpdateServiceStaticIP(ctx context.Context, oldip *common.ServiceStaticIP, ...) error
Constants ¶
View Source
const ( // The status of one table TableStatusCreating = "CREATING" TableStatusUpdating = "UPDATING" TableStatusDeleting = "DELETING" TableStatusActive = "ACTIVE" ClusterName = "ClusterName" DeviceName = "DeviceName" ServiceName = "ServiceName" ServiceUUID = "ServiceUUID" Revision = "Revision" LastModified = "LastModified" ServiceMeta = "ServiceMeta" ServiceSpec = "ServiceSpec" MemberName = "MemberName" MemberMeta = "MemberMeta" MemberSpec = "MemberSpec" ConfigFileID = "ConfigFileID" ConfigFileMeta = "ConfigFileMeta" ConfigFileSpec = "ConfigFileSpec" StaticIP = "StaticIP" StaticIPSpec = "StaticIPSpec" )
View Source
const ( StrErrDBInternal = "DB Internal Error" StrErrDBLimitExceeded = "DB LimitExceeded" StrErrDBTableInUse = "DB TableInUse" StrErrDBResourceNotFound = "DB ResourceNotFound" StrErrDBTableNotFound = "DB TableNotFound" StrErrDBRecordNotFound = "DB RecordNotFound" StrErrDBConditionalCheckFailed = "DB ConditionalCheckFailed" StrErrDBInvalidRequest = "DB invalid request" )
View Source
const ( // Service members need to be created in advance. So TaskID, ContainerInstanceID // and ServerInstanceID would be empty at service member creation. // set them to default values, this will help the later conditional update. DefaultTaskID = "defaultTaskID" DefaultContainerInstanceID = "defaultContainerInstanceID" DefaultServerInstanceID = "defaultServerInstanceID" )
Variables ¶
View Source
var ( ErrDBInternal = errors.New(StrErrDBInternal) ErrDBLimitExceeded = errors.New(StrErrDBLimitExceeded) ErrDBTableInUse = errors.New(StrErrDBTableInUse) ErrDBTableNotFound = errors.New(StrErrDBTableNotFound) // ResourceNotFound is for dynamodb table. // Table which is being requested does not exist, or is too early in the CREATING state. // https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html ErrDBResourceNotFound = errors.New(StrErrDBResourceNotFound) // RecordNotFound is when the key does not exist in db. ErrDBRecordNotFound = errors.New(StrErrDBRecordNotFound) ErrDBConditionalCheckFailed = errors.New(StrErrDBConditionalCheckFailed) ErrDBInvalidRequest = errors.New(StrErrDBInvalidRequest) )
Define the possible errors returned by DB interfaces
Functions ¶
func CopyConfigFile ¶ added in v0.9.6
func CopyConfigFile(c *common.ConfigFile) *common.ConfigFile
func CopyConfigFileMeta ¶ added in v0.9.6
func CopyConfigFileMeta(c *common.ConfigFileMeta) *common.ConfigFileMeta
func CopyConfigFileSpec ¶ added in v0.9.6
func CopyConfigFileSpec(c *common.ConfigFileSpec) *common.ConfigFileSpec
func CopyMemberMeta ¶ added in v0.9.6
func CopyMemberMeta(m *common.MemberMeta) *common.MemberMeta
func CopyMemberSpec ¶ added in v0.9.6
func CopyMemberSpec(m *common.MemberSpec) *common.MemberSpec
func CopyMemberVolumes ¶ added in v0.9.6
func CopyMemberVolumes(v *common.MemberVolumes) *common.MemberVolumes
func CopyServiceAttr ¶ added in v0.9.6
func CopyServiceAttr(s *common.ServiceAttr) *common.ServiceAttr
func CopyServiceMember ¶ added in v0.9.6
func CopyServiceMember(m *common.ServiceMember) *common.ServiceMember
func CopyServiceMeta ¶ added in v0.9.6
func CopyServiceMeta(s *common.ServiceMeta) *common.ServiceMeta
func CopyServiceSpec ¶ added in v0.9.6
func CopyServiceSpec(s *common.ServiceSpec) *common.ServiceSpec
func CopyServiceStaticIP ¶ added in v0.9.6
func CopyServiceStaticIP(s *common.ServiceStaticIP) *common.ServiceStaticIP
func CopyServiceVolume ¶ added in v0.9.6
func CopyServiceVolume(v *common.ServiceVolume) *common.ServiceVolume
func CopyServiceVolumes ¶ added in v0.9.6
func CopyServiceVolumes(v *common.ServiceVolumes) *common.ServiceVolumes
func CopyStaticIPSpec ¶ added in v0.9.6
func CopyStaticIPSpec(s *common.StaticIPSpec) *common.StaticIPSpec
func CreateConfigFile ¶
func CreateConfigFile(serviceUUID string, fileID string, revision int64, meta *common.ConfigFileMeta, spec *common.ConfigFileSpec) *common.ConfigFile
func CreateConfigFileMeta ¶ added in v0.9.6
func CreateConfigFileMeta(fileName string, mtime int64) *common.ConfigFileMeta
func CreateConfigFileSpec ¶ added in v0.9.6
func CreateConfigFileSpec(fileMode uint32, fileMD5 string, content string) *common.ConfigFileSpec
func CreateInitialConfigFile ¶
func CreateInitialMemberSpec ¶ added in v0.9.6
func CreateInitialMemberSpec(az string, vols *common.MemberVolumes, staticIP string, configs []common.ConfigID) *common.MemberSpec
func CreateMemberMeta ¶ added in v0.9.6
func CreateMemberMeta(mtime int64, status string) *common.MemberMeta
func CreateMemberSpec ¶ added in v0.9.6
func CreateNewConfigFile ¶ added in v0.9.6
func CreateNewConfigFile(c *common.ConfigFile, newFileID string, newContent string) *common.ConfigFile
func CreateService ¶
func CreateServiceAttr ¶
func CreateServiceAttr(serviceUUID string, revision int64, meta *common.ServiceMeta, spec *common.ServiceSpec) *common.ServiceAttr
func CreateServiceMember ¶
func CreateServiceMember(serviceUUID string, memberName string, revision int64, meta *common.MemberMeta, spec *common.MemberSpec) *common.ServiceMember
func CreateServiceMeta ¶ added in v0.9.6
func CreateServiceSpec ¶ added in v0.9.6
func CreateServiceStaticIP ¶ added in v0.8.1
func CreateServiceStaticIP(staticIP string, revision int64, spec *common.StaticIPSpec) *common.ServiceStaticIP
func CreateStaticIPSpec ¶ added in v0.9.6
func EqualConfigFile ¶
func EqualConfigFile(c1 *common.ConfigFile, c2 *common.ConfigFile, skipMtime bool, skipContent bool) bool
func EqualConfigs ¶ added in v0.9.6
func EqualMemberMeta ¶ added in v0.9.6
func EqualMemberMeta(m1 *common.MemberMeta, m2 *common.MemberMeta, skipMtime bool) bool
func EqualMemberSpec ¶ added in v0.9.6
func EqualMemberSpec(m1 *common.MemberSpec, m2 *common.MemberSpec) bool
func EqualMemberVolumes ¶ added in v0.9.1
func EqualMemberVolumes(v1 *common.MemberVolumes, v2 *common.MemberVolumes) bool
func EqualResources ¶ added in v0.9.2
func EqualServiceAttr ¶
func EqualServiceAttr(s1 *common.ServiceAttr, s2 *common.ServiceAttr, skipMtime bool, skipRevision bool) bool
func EqualServiceAttrImmutableFields ¶ added in v0.9.6
func EqualServiceAttrImmutableFields(s1 *common.ServiceAttr, s2 *common.ServiceAttr) bool
func EqualServiceMember ¶
func EqualServiceMember(t1 *common.ServiceMember, t2 *common.ServiceMember, skipMtime bool) bool
func EqualServiceMemberImmutableFields ¶ added in v0.9.6
func EqualServiceMemberImmutableFields(m1 *common.ServiceMember, m2 *common.ServiceMember) bool
func EqualServiceMeta ¶ added in v0.9.6
func EqualServiceMeta(s1 *common.ServiceMeta, s2 *common.ServiceMeta, skipMtime bool) bool
func EqualServiceSpec ¶ added in v0.9.6
func EqualServiceSpec(s1 *common.ServiceSpec, s2 *common.ServiceSpec) bool
func EqualServiceStaticIP ¶ added in v0.8.1
func EqualServiceStaticIP(t1 *common.ServiceStaticIP, t2 *common.ServiceStaticIP) bool
func EqualServiceStaticIPImmutableFields ¶ added in v0.9.6
func EqualServiceStaticIPImmutableFields(t1 *common.ServiceStaticIP, t2 *common.ServiceStaticIP) bool
func EqualServiceVolume ¶ added in v0.9.1
func EqualServiceVolume(v1 *common.ServiceVolume, v2 *common.ServiceVolume) bool
func EqualServiceVolumes ¶ added in v0.9.1
func EqualServiceVolumes(v1 *common.ServiceVolumes, v2 *common.ServiceVolumes) bool
func EqualStaticIPSpec ¶ added in v0.9.6
func EqualStaticIPSpec(t1 *common.StaticIPSpec, t2 *common.StaticIPSpec) bool
func PrintConfigFile ¶
func PrintConfigFile(cfg *common.ConfigFile) string
func UpdateServiceConfig ¶ added in v0.9.6
func UpdateServiceConfig(s *common.ServiceAttr, cfgIndex int, newFileID string, fileMD5 string) *common.ServiceAttr
func UpdateServiceMemberConfigs ¶
func UpdateServiceMemberConfigs(t1 *common.ServiceMember, c []common.ConfigID) *common.ServiceMember
func UpdateServiceMemberOwner ¶
func UpdateServiceMemberOwner(t1 *common.ServiceMember, taskID string, containerInstanceID string, serverInstanceID string) *common.ServiceMember
func UpdateServiceReplicas ¶ added in v0.9.2
func UpdateServiceReplicas(s *common.ServiceAttr, replicas int64) *common.ServiceAttr
func UpdateServiceResources ¶ added in v0.9.6
func UpdateServiceResources(s *common.ServiceAttr, res *common.Resources) *common.ServiceAttr
func UpdateServiceStaticIP ¶ added in v0.8.1
func UpdateServiceStaticIP(t1 *common.ServiceStaticIP, serverInstanceID string, netInterfaceID string) *common.ServiceStaticIP
func UpdateServiceStatus ¶ added in v0.9.2
func UpdateServiceStatus(s *common.ServiceAttr, status string) *common.ServiceAttr
Types ¶
type DB ¶
type DB interface { CreateSystemTables(ctx context.Context) error SystemTablesReady(ctx context.Context) (tableStatus string, ready bool, err error) DeleteSystemTables(ctx context.Context) error CreateDevice(ctx context.Context, dev *common.Device) error GetDevice(ctx context.Context, clusterName string, deviceName string) (dev *common.Device, err error) DeleteDevice(ctx context.Context, clusterName string, deviceName string) error ListDevices(ctx context.Context, clusterName string) (devs []*common.Device, err error) CreateService(ctx context.Context, svc *common.Service) error GetService(ctx context.Context, clusterName string, serviceName string) (svc *common.Service, err error) DeleteService(ctx context.Context, clusterName string, serviceName string) error ListServices(ctx context.Context, clusterName string) (svcs []*common.Service, err error) CreateServiceAttr(ctx context.Context, attr *common.ServiceAttr) error // Only support updating ServiceStatus, Replicas or UserAttr at v1, all other attributes are immutable. UpdateServiceAttr(ctx context.Context, oldAttr *common.ServiceAttr, newAttr *common.ServiceAttr) error GetServiceAttr(ctx context.Context, serviceUUID string) (attr *common.ServiceAttr, err error) DeleteServiceAttr(ctx context.Context, serviceUUID string) error CreateServiceMember(ctx context.Context, member *common.ServiceMember) error UpdateServiceMember(ctx context.Context, oldMember *common.ServiceMember, newMember *common.ServiceMember) error GetServiceMember(ctx context.Context, serviceUUID string, memberName string) (member *common.ServiceMember, err error) ListServiceMembers(ctx context.Context, serviceUUID string) (members []*common.ServiceMember, err error) DeleteServiceMember(ctx context.Context, serviceUUID string, memberName string) error CreateConfigFile(ctx context.Context, cfg *common.ConfigFile) error GetConfigFile(ctx context.Context, serviceUUID string, fileID string) (cfg *common.ConfigFile, err error) DeleteConfigFile(ctx context.Context, serviceUUID string, fileID string) error CreateServiceStaticIP(ctx context.Context, serviceip *common.ServiceStaticIP) error UpdateServiceStaticIP(ctx context.Context, oldip *common.ServiceStaticIP, newip *common.ServiceStaticIP) error GetServiceStaticIP(ctx context.Context, ip string) (serviceip *common.ServiceStaticIP, err error) DeleteServiceStaticIP(ctx context.Context, ip string) error }
DB defines the DB interfaces
The design aims to provide the flexibility to support different type of key-value DBs. For example, could use the simple embedded controlDB, DynamoDB, etcd, zk, etc. There are 2 requirements: 1) conditional creation/update (create-if-not-exist and update-if-match). 2) strong consistency on get/list.
The device/service/serviceattr/servicemember/configfile creations are create-if-not-exist. If item exists in DB, the ErrDBConditionalCheckFailed error will be returned.
The serviceattr/servicemember updates are also update-if-match the old item. Return ErrDBConditionalCheckFailed as well if not match.
type MemDB ¶
type MemDB struct {
// contains filtered or unexported fields
}
func (*MemDB) CreateConfigFile ¶
func (*MemDB) CreateDevice ¶
func (*MemDB) CreateService ¶
func (*MemDB) CreateServiceAttr ¶
func (*MemDB) CreateServiceMember ¶
func (*MemDB) CreateServiceStaticIP ¶ added in v0.8.1
func (*MemDB) DeleteConfigFile ¶
func (*MemDB) DeleteDevice ¶
func (*MemDB) DeleteService ¶
func (*MemDB) DeleteServiceAttr ¶
func (*MemDB) DeleteServiceMember ¶
func (*MemDB) DeleteServiceStaticIP ¶ added in v0.8.1
func (*MemDB) GetConfigFile ¶
func (*MemDB) GetService ¶
func (*MemDB) GetServiceAttr ¶
func (*MemDB) GetServiceMember ¶
func (*MemDB) GetServiceStaticIP ¶ added in v0.8.1
func (*MemDB) ListDevices ¶
func (*MemDB) ListServiceMembers ¶
func (*MemDB) ListServices ¶
func (*MemDB) SystemTablesReady ¶
func (*MemDB) UpdateServiceAttr ¶
func (d *MemDB) UpdateServiceAttr(ctx context.Context, oldAttr *common.ServiceAttr, newAttr *common.ServiceAttr) error
func (*MemDB) UpdateServiceMember ¶
func (d *MemDB) UpdateServiceMember(ctx context.Context, oldMember *common.ServiceMember, newMember *common.ServiceMember) error
func (*MemDB) UpdateServiceStaticIP ¶ added in v0.8.1
func (d *MemDB) UpdateServiceStaticIP(ctx context.Context, oldip *common.ServiceStaticIP, newip *common.ServiceStaticIP) error
Click to show internal directories.
Click to hide internal directories.