Documentation ¶
Index ¶
- Constants
- type DynamoDB
- func (d *DynamoDB) AddManagerAddrs(ctx context.Context, clusterName string, oldAddrs string, newAddrs string) error
- func (d *DynamoDB) CreateConfigFile(ctx context.Context, cfg *common.ConfigFile) error
- func (d *DynamoDB) CreateDevice(ctx context.Context, dev *common.Device) error
- func (d *DynamoDB) CreateJoinToken(ctx context.Context, clusterName string, token string, role string) error
- func (d *DynamoDB) CreateService(ctx context.Context, svc *common.Service) error
- func (d *DynamoDB) CreateServiceAttr(ctx context.Context, attr *common.ServiceAttr) error
- func (d *DynamoDB) CreateServiceMember(ctx context.Context, member *common.ServiceMember) error
- func (d *DynamoDB) CreateServiceStaticIP(ctx context.Context, serviceip *common.ServiceStaticIP) error
- func (d *DynamoDB) CreateSystemTables(ctx context.Context) error
- func (d *DynamoDB) DeleteConfigFile(ctx context.Context, serviceUUID string, fileID string) error
- func (d *DynamoDB) DeleteDevice(ctx context.Context, clusterName string, deviceName string) error
- func (d *DynamoDB) DeleteService(ctx context.Context, clusterName string, serviceName string) error
- func (d *DynamoDB) DeleteServiceAttr(ctx context.Context, serviceUUID string) error
- func (d *DynamoDB) DeleteServiceMember(ctx context.Context, serviceUUID string, memberName string) error
- func (d *DynamoDB) DeleteServiceStaticIP(ctx context.Context, staticIP string) error
- func (d *DynamoDB) DeleteSystemTables(ctx context.Context) error
- func (d *DynamoDB) GetConfigFile(ctx context.Context, serviceUUID string, fileID string) (cfg *common.ConfigFile, err error)
- func (d *DynamoDB) GetDevice(ctx context.Context, clusterName string, deviceName string) (dev *common.Device, err error)
- func (d *DynamoDB) GetInitManager(ctx context.Context, clusterName string) (addr string, err error)
- func (d *DynamoDB) GetJoinToken(ctx context.Context, clusterName string, role string) (token string, err error)
- func (d *DynamoDB) GetManagerAddrs(ctx context.Context, clusterName string) (addrs string, err error)
- func (d *DynamoDB) GetService(ctx context.Context, clusterName string, serviceName string) (svc *common.Service, err error)
- func (d *DynamoDB) GetServiceAttr(ctx context.Context, serviceUUID string) (attr *common.ServiceAttr, err error)
- func (d *DynamoDB) GetServiceMember(ctx context.Context, serviceUUID string, memberName string) (member *common.ServiceMember, err error)
- func (d *DynamoDB) GetServiceStaticIP(ctx context.Context, staticIP string) (serviceip *common.ServiceStaticIP, err error)
- func (d *DynamoDB) ListDevices(ctx context.Context, clusterName string) (devs []*common.Device, err error)
- func (d *DynamoDB) ListServiceMembers(ctx context.Context, serviceUUID string) (serviceMembers []*common.ServiceMember, err error)
- func (d *DynamoDB) ListServices(ctx context.Context, clusterName string) (services []*common.Service, err error)
- func (d *DynamoDB) SystemTablesReady(ctx context.Context) (tableStatus string, ready bool, err error)
- func (d *DynamoDB) TakeInitManager(ctx context.Context, clusterName string, addr string) error
- func (d *DynamoDB) UpdateServiceAttr(ctx context.Context, oldAttr *common.ServiceAttr, newAttr *common.ServiceAttr) error
- func (d *DynamoDB) UpdateServiceMember(ctx context.Context, oldMember *common.ServiceMember, ...) error
- func (d *DynamoDB) UpdateServiceStaticIP(ctx context.Context, oldIP *common.ServiceStaticIP, ...) error
- func (d *DynamoDB) WaitSystemTablesDeleted(ctx context.Context, maxWaitSeconds int64) error
- func (d *DynamoDB) WaitSystemTablesReady(ctx context.Context, maxWaitSeconds int64) error
Constants ¶
const ( InternalServerError = "InternalServerError" LimitExceededException = "LimitExceededException" TableInUseException = "TableInUseException" ResourceNotFoundException = "ResourceNotFoundException" TableNotFoundException = "TableNotFoundException" ConditionalCheckFailedException = "ConditionalCheckFailedException" ProvisionedThroughputExceededException = "ProvisionedThroughputExceededException" )
DynamoDB related const
const ( RoleWorker = "worker" RoleManager = "manager" )
DynamoDB related const
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DynamoDB ¶
type DynamoDB struct {
// contains filtered or unexported fields
}
DynamoDB implements DB interfae on dynamodb
func NewDynamoDB ¶
NewDynamoDB allocates a new DynamoDB instance
DB requirements: 1) conditional creation/update. 2) strong consistency on get/list.
DynamoDB could easily achieve both. Azure table has insert and update APIs.
Q: sounds Azure table is strong consistency for the single key? as table builds on top of Azure storage, which is strongly consistent. - insert: assume creating new entry, and will return EntityAlreadyExists if entry exists - update: support etag, assume updating existing entry, and will return error if entry doesn't exist [1] https://azure.microsoft.com/en-us/documentation/articles/storage-table-design-guide/ [2] https://msdn.microsoft.com/en-us/library/dd894033.aspx
GCP datastore also provides the similar NoSQL DB. Looks guarantee strong consistency is more complex?
- upsert, overwrite an entity if exists. Q: return error if not exist?
- insert, requires the entity key not already exist. see example code, actually use RunInTx: get check and then put. Q: conditional update follows the same way?
- lookup, retrieves an entity. "strong consistency (an ancestor query, or a lookup of a single entity)"[1]. Q: sounds datastore is strong consistency for the single key operations (upsert, insert, lookup)?
- list, "Ancestor queries (those that execute against an entity group) are strongly consistent"[1]. [1] https://cloud.google.com/datastore/docs/concepts/structuring_for_strong_consistency [2] https://cloud.google.com/datastore/docs/concepts/entities [3] https://cloud.google.com/datastore/docs/best-practices [4] https://cloud.google.com/datastore/docs/concepts/transaction
func NewTestDynamoDB ¶
NewTestDynamoDB creates a DynamoDB instance for test
func (*DynamoDB) AddManagerAddrs ¶ added in v0.9.4
func (d *DynamoDB) AddManagerAddrs(ctx context.Context, clusterName string, oldAddrs string, newAddrs string) error
AddManagerAddrs updates the managerAddrs record in db
func (*DynamoDB) CreateConfigFile ¶
CreateConfigFile creates one config file in DB
func (*DynamoDB) CreateDevice ¶
CreateDevice puts a new Device into DB
func (*DynamoDB) CreateJoinToken ¶
func (d *DynamoDB) CreateJoinToken(ctx context.Context, clusterName string, token string, role string) error
CreateJoinToken puts the worker/manager join token in DB.
func (*DynamoDB) CreateService ¶
CreateService puts a new Service into DB
func (*DynamoDB) CreateServiceAttr ¶
CreateServiceAttr puts a new ServiceAttr record into DB
func (*DynamoDB) CreateServiceMember ¶
CreateServiceMember creates one EBS serviceMember in DB
func (*DynamoDB) CreateServiceStaticIP ¶ added in v0.8.1
func (d *DynamoDB) CreateServiceStaticIP(ctx context.Context, serviceip *common.ServiceStaticIP) error
CreateServiceStaticIP creates one ServiceStaticIP in DB
func (*DynamoDB) CreateSystemTables ¶
CreateSystemTables creates the system tables.
func (*DynamoDB) DeleteConfigFile ¶
DeleteConfigFile deletes the config file from DB
func (*DynamoDB) DeleteDevice ¶
DeleteDevice deletes the Device from DB. The caller should make sure the service is deleted.
func (*DynamoDB) DeleteService ¶
DeleteService deletes the service from DB
func (*DynamoDB) DeleteServiceAttr ¶
DeleteServiceAttr deletes the service attr from DB
func (*DynamoDB) DeleteServiceMember ¶
func (d *DynamoDB) DeleteServiceMember(ctx context.Context, serviceUUID string, memberName string) error
DeleteServiceMember deletes the serviceMember from DB
func (*DynamoDB) DeleteServiceStaticIP ¶ added in v0.8.1
DeleteServiceStaticIP deletes the service static ip from DB
func (*DynamoDB) DeleteSystemTables ¶
DeleteSystemTables deletes the system tables.
func (*DynamoDB) GetConfigFile ¶
func (d *DynamoDB) GetConfigFile(ctx context.Context, serviceUUID string, fileID string) (cfg *common.ConfigFile, err error)
GetConfigFile gets the config fileItem from DB
func (*DynamoDB) GetDevice ¶
func (d *DynamoDB) GetDevice(ctx context.Context, clusterName string, deviceName string) (dev *common.Device, err error)
GetDevice gets the device from DB
func (*DynamoDB) GetInitManager ¶
GetInitManager gets the init manager address from DB.
func (*DynamoDB) GetJoinToken ¶
func (d *DynamoDB) GetJoinToken(ctx context.Context, clusterName string, role string) (token string, err error)
GetJoinToken gets the worker/manager join token from DB.
func (*DynamoDB) GetManagerAddrs ¶ added in v0.9.4
func (d *DynamoDB) GetManagerAddrs(ctx context.Context, clusterName string) (addrs string, err error)
GetManagerAddrs gets the manager addresses from DB.
func (*DynamoDB) GetService ¶
func (d *DynamoDB) GetService(ctx context.Context, clusterName string, serviceName string) (svc *common.Service, err error)
GetService gets the Service from DB
func (*DynamoDB) GetServiceAttr ¶
func (d *DynamoDB) GetServiceAttr(ctx context.Context, serviceUUID string) (attr *common.ServiceAttr, err error)
GetServiceAttr gets the ServiceAttr from DB
func (*DynamoDB) GetServiceMember ¶
func (d *DynamoDB) GetServiceMember(ctx context.Context, serviceUUID string, memberName string) (member *common.ServiceMember, err error)
GetServiceMember gets the serviceMemberItem from DB
func (*DynamoDB) GetServiceStaticIP ¶ added in v0.8.1
func (d *DynamoDB) GetServiceStaticIP(ctx context.Context, staticIP string) (serviceip *common.ServiceStaticIP, err error)
GetServiceStaticIP gets the ServiceStaticIP from DB
func (*DynamoDB) ListDevices ¶
func (d *DynamoDB) ListDevices(ctx context.Context, clusterName string) (devs []*common.Device, err error)
ListDevices lists all Devices
func (*DynamoDB) ListServiceMembers ¶
func (d *DynamoDB) ListServiceMembers(ctx context.Context, serviceUUID string) (serviceMembers []*common.ServiceMember, err error)
ListServiceMembers lists all serviceMembers of the service
func (*DynamoDB) ListServices ¶
func (d *DynamoDB) ListServices(ctx context.Context, clusterName string) (services []*common.Service, err error)
ListServices lists all services
func (*DynamoDB) SystemTablesReady ¶
func (d *DynamoDB) SystemTablesReady(ctx context.Context) (tableStatus string, ready bool, err error)
SystemTablesReady checks if all system tables are ready to use
func (*DynamoDB) TakeInitManager ¶
TakeInitManager tries to become the first manager that initializes the swarm cluster and persists the join tokens.
func (*DynamoDB) UpdateServiceAttr ¶
func (d *DynamoDB) UpdateServiceAttr(ctx context.Context, oldAttr *common.ServiceAttr, newAttr *common.ServiceAttr) error
UpdateServiceAttr updates the ServiceAttr in DB. Only support updating ServiceStatus, Replicas, ServiceConfigs or UserAttr at v1, all other attributes are immutable.
func (*DynamoDB) UpdateServiceMember ¶
func (d *DynamoDB) UpdateServiceMember(ctx context.Context, oldMember *common.ServiceMember, newMember *common.ServiceMember) error
UpdateServiceMember updates the ServiceMember in DB
func (*DynamoDB) UpdateServiceStaticIP ¶ added in v0.8.1
func (d *DynamoDB) UpdateServiceStaticIP(ctx context.Context, oldIP *common.ServiceStaticIP, newIP *common.ServiceStaticIP) error
UpdateServiceStaticIP updates the ServiceStaticIP in DB
func (*DynamoDB) WaitSystemTablesDeleted ¶
WaitSystemTablesDeleted waits till all system tables are deleted.