Documentation ¶
Index ¶
- Constants
- Variables
- func CopyMemberConfigs(c1 []*common.MemberConfig) []*common.MemberConfig
- func CreateConfigFile(serviceUUID string, fileID string, fileMD5 string, fileName string, ...) (*common.ConfigFile, error)
- func CreateDevice(cluster string, device string, service string) *common.Device
- func CreateInitialConfigFile(serviceUUID string, fileID string, fileName string, fileMode uint32, ...) *common.ConfigFile
- func CreateInitialServiceAttr(serviceUUID string, replicas int64, cluster string, service string, ...) *common.ServiceAttr
- func CreateInitialServiceMember(serviceUUID string, memberIndex int64, memberName string, az string, ...) *common.ServiceMember
- func CreateService(cluster string, service string, serviceUUID string) *common.Service
- func CreateServiceAttr(serviceUUID string, status string, mtime int64, replicas int64, cluster string, ...) *common.ServiceAttr
- func CreateServiceMember(serviceUUID string, memberIndex int64, memberName string, az string, ...) *common.ServiceMember
- func CreateServiceStaticIP(staticIP string, serviceUUID string, az string, serverInstanceID string, ...) *common.ServiceStaticIP
- func EqualConfigFile(c1 *common.ConfigFile, c2 *common.ConfigFile, skipMtime bool, skipContent bool) bool
- func EqualDevice(t1 *common.Device, t2 *common.Device) bool
- func EqualMemberVolumes(v1 *common.MemberVolumes, v2 *common.MemberVolumes) bool
- func EqualService(t1 *common.Service, t2 *common.Service) bool
- func EqualServiceAttr(t1 *common.ServiceAttr, t2 *common.ServiceAttr, skipMtime bool) bool
- func EqualServiceMember(t1 *common.ServiceMember, t2 *common.ServiceMember, skipMtime bool) bool
- func EqualServiceStaticIP(t1 *common.ServiceStaticIP, t2 *common.ServiceStaticIP) bool
- func EqualServiceUserAttr(u1 *common.ServiceUserAttr, u2 *common.ServiceUserAttr) bool
- func EqualServiceVolume(v1 *common.ServiceVolume, v2 *common.ServiceVolume) bool
- func EqualServiceVolumes(v1 *common.ServiceVolumes, v2 *common.ServiceVolumes) bool
- func PrintConfigFile(cfg *common.ConfigFile) string
- func UpdateConfigFile(c *common.ConfigFile, newFileID string, newContent string) *common.ConfigFile
- func UpdateServiceAttr(t1 *common.ServiceAttr, status string) *common.ServiceAttr
- func UpdateServiceMemberConfigs(t1 *common.ServiceMember, c []*common.MemberConfig) *common.ServiceMember
- func UpdateServiceMemberOwner(t1 *common.ServiceMember, taskID string, containerInstanceID string, ...) *common.ServiceMember
- func UpdateServiceStaticIP(t1 *common.ServiceStaticIP, serverInstanceID string, netInterfaceID string) *common.ServiceStaticIP
- 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, memberIndex int64) 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, memberIndex int64) (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" )
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) ErrDBResourceNotFound = errors.New(StrErrDBResourceNotFound) ErrDBRecordNotFound = errors.New(StrErrDBRecordNotFound) ErrDBConditionalCheckFailed = errors.New(StrErrDBConditionalCheckFailed) ErrDBInvalidRequest = errors.New(StrErrDBInvalidRequest) )
Define the possible errors returned by DB interfaces
Functions ¶
func CopyMemberConfigs ¶
func CopyMemberConfigs(c1 []*common.MemberConfig) []*common.MemberConfig
func CreateConfigFile ¶
func CreateInitialConfigFile ¶
func CreateInitialServiceAttr ¶
func CreateInitialServiceAttr(serviceUUID string, replicas int64, cluster string, service string, vols common.ServiceVolumes, registerDNS bool, domain string, hostedZoneID string, requireStaticIP bool, userAttr *common.ServiceUserAttr) *common.ServiceAttr
func CreateInitialServiceMember ¶
func CreateInitialServiceMember(serviceUUID string, memberIndex int64, memberName string, az string, vols common.MemberVolumes, staticIP string, configs []*common.MemberConfig) *common.ServiceMember
func CreateService ¶
func CreateServiceAttr ¶
func CreateServiceMember ¶
func CreateServiceMember(serviceUUID string, memberIndex int64, memberName string, az string, taskID string, containerInstanceID string, ec2InstanceID string, mtime int64, vols common.MemberVolumes, staticIP string, configs []*common.MemberConfig) *common.ServiceMember
func CreateServiceStaticIP ¶ added in v0.8.1
func EqualConfigFile ¶
func EqualConfigFile(c1 *common.ConfigFile, c2 *common.ConfigFile, skipMtime bool, skipContent bool) bool
func EqualMemberVolumes ¶ added in v0.9.1
func EqualMemberVolumes(v1 *common.MemberVolumes, v2 *common.MemberVolumes) bool
func EqualServiceAttr ¶
func EqualServiceAttr(t1 *common.ServiceAttr, t2 *common.ServiceAttr, skipMtime bool) bool
func EqualServiceMember ¶
func EqualServiceMember(t1 *common.ServiceMember, t2 *common.ServiceMember, skipMtime bool) bool
func EqualServiceStaticIP ¶ added in v0.8.1
func EqualServiceStaticIP(t1 *common.ServiceStaticIP, t2 *common.ServiceStaticIP) bool
func EqualServiceUserAttr ¶ added in v0.9.1
func EqualServiceUserAttr(u1 *common.ServiceUserAttr, u2 *common.ServiceUserAttr) 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 PrintConfigFile ¶
func PrintConfigFile(cfg *common.ConfigFile) string
func UpdateConfigFile ¶
func UpdateConfigFile(c *common.ConfigFile, newFileID string, newContent string) *common.ConfigFile
func UpdateServiceAttr ¶
func UpdateServiceAttr(t1 *common.ServiceAttr, status string) *common.ServiceAttr
func UpdateServiceMemberConfigs ¶
func UpdateServiceMemberConfigs(t1 *common.ServiceMember, c []*common.MemberConfig) *common.ServiceMember
func UpdateServiceMemberOwner ¶
func UpdateServiceMemberOwner(t1 *common.ServiceMember, taskID string, containerInstanceID string, ec2InstanceID string) *common.ServiceMember
func UpdateServiceStaticIP ¶ added in v0.8.1
func UpdateServiceStaticIP(t1 *common.ServiceStaticIP, serverInstanceID string, netInterfaceID string) *common.ServiceStaticIP
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 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, memberIndex int64) (member *common.ServiceMember, err error) ListServiceMembers(ctx context.Context, serviceUUID string) (members []*common.ServiceMember, err error) DeleteServiceMember(ctx context.Context, serviceUUID string, memberIndex int64) 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.