Documentation ¶
Index ¶
- Constants
- type AgbotPostgresqlDB
- func (db *AgbotPostgresqlDB) AgreementAttempt(agreementid string, org string, deviceid string, policyName string, ...) error
- func (db *AgbotPostgresqlDB) AgreementBlockchainUpdate(agreementId string, consumerSig string, hash string, counterParty string, ...) (*persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) AgreementBlockchainUpdateAck(agreementId string, protocol string) (*persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) AgreementFinalized(agreementId string, protocol string) (*persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) AgreementMade(agreementId string, counterParty string, signature string, protocol string, ...) (*persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) AgreementTimedout(agreementid string, protocol string) (*persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) AgreementUpdate(agreementid string, proposal string, policy string, ...) (*persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) AllPartitions() []string
- func (db *AgbotPostgresqlDB) ArchiveAgreement(agreementid string, protocol string, reason uint, desc string) (*persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) ClaimPartition(timeout uint64) (string, error)
- func (db *AgbotPostgresqlDB) Close()
- func (db *AgbotPostgresqlDB) DataNotVerified(agreementid string, protocol string) (*persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) DataNotification(agreementid string, protocol string) (*persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) DataVerified(agreementid string, protocol string) (*persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) DeleteAgreement(agreementid string, protocol string) error
- func (db *AgbotPostgresqlDB) DeleteWorkloadUsage(deviceid string, policyName string) error
- func (db *AgbotPostgresqlDB) DisableRollbackChecking(deviceid string, policyName string) (*persistence.WorkloadUsage, error)
- func (db *AgbotPostgresqlDB) FindAgreementPartitions() ([]string, error)
- func (db *AgbotPostgresqlDB) FindAgreements(filters []persistence.AFilter, protocol string) ([]persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) FindPartitions() ([]string, error)
- func (db *AgbotPostgresqlDB) FindSingleAgreementByAgreementId(agreementId string, protocol string, filters []persistence.AFilter) (*persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) FindSingleAgreementByAgreementIdAllProtocols(agreementid string, protocols []string, filters []persistence.AFilter) (*persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) FindSingleWorkloadUsageByDeviceAndPolicyName(deviceid string, policyName string) (*persistence.WorkloadUsage, error)
- func (db *AgbotPostgresqlDB) FindWorkloadUsages(filters []persistence.WUFilter) ([]persistence.WorkloadUsage, error)
- func (db *AgbotPostgresqlDB) GetAgreementCount(partition string) (int64, int64, error)
- func (db *AgbotPostgresqlDB) GetAgreementPartitionMove(fromPartition string, toPartition string) string
- func (db *AgbotPostgresqlDB) GetAgreementPartitionTableCount(partition string) string
- func (db *AgbotPostgresqlDB) GetAgreementPartitionTableDrop(partition string) string
- func (db *AgbotPostgresqlDB) GetAgreementPartitionTableExists(partition string) string
- func (db *AgbotPostgresqlDB) GetAgreementPartitionTableName(partition string) string
- func (db *AgbotPostgresqlDB) GetPartitionOwner(id string) (string, error)
- func (db *AgbotPostgresqlDB) GetPrimaryAgreementPartitionTableCreate() string
- func (db *AgbotPostgresqlDB) GetPrimaryAgreementPartitionTableIndexCreate() string
- func (db *AgbotPostgresqlDB) GetPrimaryWorkloadUsagePartitionTableCreate() string
- func (db *AgbotPostgresqlDB) GetPrimaryWorkloadUsagePartitionTableIndexCreate() string
- func (db *AgbotPostgresqlDB) GetWorkloadUsagePartitionMove(fromPartition string, toPartition string) string
- func (db *AgbotPostgresqlDB) GetWorkloadUsagePartitionTableDrop(partition string) string
- func (db *AgbotPostgresqlDB) GetWorkloadUsagePartitionTableExists(partition string) string
- func (db *AgbotPostgresqlDB) GetWorkloadUsagePartitionTableName(partition string) string
- func (db *AgbotPostgresqlDB) GetWorkloadUsagePartitionUsageTableCount(partition string) string
- func (db *AgbotPostgresqlDB) GetWorkloadUsagesCount(partition string) (int64, error)
- func (db *AgbotPostgresqlDB) HeartbeatPartition() error
- func (db *AgbotPostgresqlDB) Initialize(cfg *config.HorizonConfig) error
- func (db *AgbotPostgresqlDB) MeteringNotification(agreementid string, protocol string, mn string) (*persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) MovePartition(timeout uint64) error
- func (db *AgbotPostgresqlDB) NewWorkloadUsage(deviceId string, hapartners []string, policy string, policyName string, ...) error
- func (db *AgbotPostgresqlDB) PrimaryPartition() string
- func (db *AgbotPostgresqlDB) QuiescePartition() error
- func (db *AgbotPostgresqlDB) SingleAgreementUpdate(agreementid string, protocol string, ...) (*persistence.Agreement, error)
- func (db *AgbotPostgresqlDB) SingleWorkloadUsageUpdate(deviceid string, policyName string, ...) (*persistence.WorkloadUsage, error)
- func (db *AgbotPostgresqlDB) String() string
- func (db *AgbotPostgresqlDB) UpdatePendingUpgrade(deviceid string, policyName string) (*persistence.WorkloadUsage, error)
- func (db *AgbotPostgresqlDB) UpdatePolicy(deviceid string, policyName string, pol string) (*persistence.WorkloadUsage, error)
- func (db *AgbotPostgresqlDB) UpdatePriority(deviceid string, policyName string, priority int, retryDurationS int, ...) (*persistence.WorkloadUsage, error)
- func (db *AgbotPostgresqlDB) UpdateRetryCount(deviceid string, policyName string, retryCount int, agid string) (*persistence.WorkloadUsage, error)
- func (db *AgbotPostgresqlDB) UpdateWUAgreementId(deviceid string, policyName string, agid string, protocol string) (*persistence.WorkloadUsage, error)
- func (db *AgbotPostgresqlDB) VerifyPartitions(partitions []string) ([]string, error)
- type SchemaUpdate
Constants ¶
const AGREEMENT_COUNT = `SELECT agreement FROM "agreements_;`
const AGREEMENT_CREATE_MAIN_TABLE = `` /* 209-byte string literal not displayed */
const AGREEMENT_CREATE_PARTITION_INDEX = `CREATE INDEX IF NOT EXISTS "agreement_id_index_on_agreements_ ON "agreements_ (agreement_id);`
const AGREEMENT_CREATE_PARTITION_TABLE = `CREATE TABLE IF NOT EXISTS "agreements_ (
CHECK ( partition = 'partition_name' )
) INHERITS (agreements);`
const AGREEMENT_DELETE = `DELETE FROM "agreements_ WHERE agreement_id = $1;`
const AGREEMENT_DROP_PARTITION = `DROP TABLE "agreements_;`
const AGREEMENT_INSERT = `INSERT INTO "agreements_ (agreement_id, protocol, partition, agreement) VALUES ($1, $2, $3, $4);`
const AGREEMENT_MOVE = `` /* 256-byte string literal not displayed */
const AGREEMENT_PARTITIONS = `SELECT partition FROM agreements;`
const AGREEMENT_PARTITION_EMPTY = `SELECT agreement_id FROM "agreements_;`
const AGREEMENT_PARTITION_FILLIN = `partition_name`
const AGREEMENT_PARTITION_TABLE_EXISTS = `SELECT to_regclass('agreements_');`
Please note that the following SQL statement has a different syntax where the table name is specified. Note the use of single quotes instead of double quotes that are used in all the other SQL. Don't ya just love SQL syntax consistency.
const AGREEMENT_QUERY = `SELECT agreement FROM "agreements_ WHERE agreement_id = $1 AND protocol = $2;`
const AGREEMENT_TABLE_NAME_ROOT = `agreements_`
const AGREEMENT_UPDATE = `UPDATE "agreements_ SET agreement = $3, updated = current_timestamp WHERE agreement_id = $1 AND protocol = $2;`
const ALL_AGREEMENTS_QUERY = `SELECT agreement FROM "agreements_ WHERE protocol = $1;`
const ALL_WORKLOAD_USAGE_QUERY = `SELECT workload_usage FROM "workload_usages_;`
const HIGHEST_DATABASE_VERSION = v1
const PARTITION_CLAIM_UNOWNED_BY_FUNCTION = `SELECT * FROM claim_ownerless($1, $2);`
const PARTITION_CLAIM_UNOWNED_FUNCTION = `` /* 557-byte string literal not displayed */
The complexity of the WHERE clause should not be underestimated. Each row is scanned whlie the table is locked so we are sure that no other agbot can even read this table until this query is complete. This query runs in a transaction that is controlled by the functions in this package.
const PARTITION_CREATE_MAIN_TABLE = `CREATE TABLE IF NOT EXISTS partitions (
id SERIAL PRIMARY KEY,
owner text,
heartbeat timestamp with time zone
);`
const PARTITION_DELETE = `DELETE FROM partitions WHERE id = $1;`
const PARTITION_HEARTBEAT = `UPDATE partitions SET heartbeat = current_timestamp WHERE id = $1 AND owner = $2;`
const PARTITION_INSERT = `INSERT INTO partitions (owner, heartbeat) VALUES ($1,current_timestamp) RETURNING id, owner;`
const PARTITION_OWNER = `SELECT owner FROM partitions WHERE id = $1;`
const PARTITION_QUIESCE = `UPDATE partitions SET owner = NULL, heartbeat = NULL WHERE owner = $1;`
const VERSION_CREATE_TABLE = `` /* 170-byte string literal not displayed */
version schema: ver: The current version of the database schema. updated: A timestamp to record last updated time.
const VERSION_INSERT = `` /* 162-byte string literal not displayed */
There should only be 1 row in this table.
const VERSION_QUERY = `SELECT ver, description, updated FROM version WHERE id = 1;`
const VERSION_UPDATE = `UPDATE version SET ver = $1, description = $2, updated = current_timestamp WHERE id = 1;`
const WORKLOAD_USAGE_COUNT = `SELECT COUNT(*) FROM "workload_usages_;`
const WORKLOAD_USAGE_CREATE_MAIN_TABLE = `` /* 219-byte string literal not displayed */
const WORKLOAD_USAGE_CREATE_PARTITION_INDEX = `CREATE INDEX IF NOT EXISTS "device_index_on_workload_usages_ ON "workload_usages_ (device_id, policy_name);`
const WORKLOAD_USAGE_CREATE_PARTITION_TABLE = `CREATE TABLE IF NOT EXISTS "workload_usages_ (
CHECK ( partition = 'partition_name' )
) INHERITS (workload_usages);`
const WORKLOAD_USAGE_DELETE = `DELETE FROM "workload_usages_ WHERE device_id = $1 AND policy_name = $2;`
const WORKLOAD_USAGE_DROP_PARTITION = `DROP TABLE "workload_usages_;`
const WORKLOAD_USAGE_INSERT = `INSERT INTO "workload_usages_ (device_id, policy_name, partition, workload_usage) VALUES ($1, $2, $3, $4);`
const WORKLOAD_USAGE_MOVE = `` /* 281-byte string literal not displayed */
const WORKLOAD_USAGE_PARTITION_FILLIN = `partition_name`
const WORKLOAD_USAGE_PARTITION_TABLE_EXISTS = `SELECT to_regclass('workload_usages_');`
Please note that the following SQL statement has a different syntax where the table name is specified. Note the use of single quotes instead of double quotes that are used in all the other SQL. Don't ya just love SQL syntax consistency.
const WORKLOAD_USAGE_QUERY = `SELECT workload_usage FROM "workload_usages_ WHERE device_id = $1 AND policy_name = $2;`
const WORKLOAD_USAGE_TABLE_NAME_ROOT = `workload_usages_`
const WORKLOAD_USAGE_UPDATE = `UPDATE "workload_usages_ SET workload_usage = $3, updated = current_timestamp WHERE device_id = $1 AND policy_name = $2;`
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgbotPostgresqlDB ¶
type AgbotPostgresqlDB struct {
// contains filtered or unexported fields
}
The fields in this object are initialized in the Initialize method in this package.
func (*AgbotPostgresqlDB) AgreementAttempt ¶
func (*AgbotPostgresqlDB) AgreementBlockchainUpdate ¶
func (db *AgbotPostgresqlDB) AgreementBlockchainUpdate(agreementId string, consumerSig string, hash string, counterParty string, signature string, protocol string) (*persistence.Agreement, error)
func (*AgbotPostgresqlDB) AgreementBlockchainUpdateAck ¶
func (db *AgbotPostgresqlDB) AgreementBlockchainUpdateAck(agreementId string, protocol string) (*persistence.Agreement, error)
func (*AgbotPostgresqlDB) AgreementFinalized ¶
func (db *AgbotPostgresqlDB) AgreementFinalized(agreementId string, protocol string) (*persistence.Agreement, error)
func (*AgbotPostgresqlDB) AgreementMade ¶
func (*AgbotPostgresqlDB) AgreementTimedout ¶
func (db *AgbotPostgresqlDB) AgreementTimedout(agreementid string, protocol string) (*persistence.Agreement, error)
func (*AgbotPostgresqlDB) AgreementUpdate ¶
func (db *AgbotPostgresqlDB) AgreementUpdate(agreementid string, proposal string, policy string, dvPolicy policy.DataVerification, defaultCheckRate uint64, hash string, sig string, protocol string, agreementProtoVersion int) (*persistence.Agreement, error)
func (*AgbotPostgresqlDB) AllPartitions ¶
func (db *AgbotPostgresqlDB) AllPartitions() []string
func (*AgbotPostgresqlDB) ArchiveAgreement ¶
func (db *AgbotPostgresqlDB) ArchiveAgreement(agreementid string, protocol string, reason uint, desc string) (*persistence.Agreement, error)
func (*AgbotPostgresqlDB) ClaimPartition ¶
func (db *AgbotPostgresqlDB) ClaimPartition(timeout uint64) (string, error)
Look for an ownerless or stale partition. If none exist, create a new partition.
func (*AgbotPostgresqlDB) Close ¶
func (db *AgbotPostgresqlDB) Close()
func (*AgbotPostgresqlDB) DataNotVerified ¶
func (db *AgbotPostgresqlDB) DataNotVerified(agreementid string, protocol string) (*persistence.Agreement, error)
func (*AgbotPostgresqlDB) DataNotification ¶
func (db *AgbotPostgresqlDB) DataNotification(agreementid string, protocol string) (*persistence.Agreement, error)
func (*AgbotPostgresqlDB) DataVerified ¶
func (db *AgbotPostgresqlDB) DataVerified(agreementid string, protocol string) (*persistence.Agreement, error)
func (*AgbotPostgresqlDB) DeleteAgreement ¶
func (db *AgbotPostgresqlDB) DeleteAgreement(agreementid string, protocol string) error
func (*AgbotPostgresqlDB) DeleteWorkloadUsage ¶
func (db *AgbotPostgresqlDB) DeleteWorkloadUsage(deviceid string, policyName string) error
func (*AgbotPostgresqlDB) DisableRollbackChecking ¶
func (db *AgbotPostgresqlDB) DisableRollbackChecking(deviceid string, policyName string) (*persistence.WorkloadUsage, error)
func (*AgbotPostgresqlDB) FindAgreementPartitions ¶
func (db *AgbotPostgresqlDB) FindAgreementPartitions() ([]string, error)
func (*AgbotPostgresqlDB) FindAgreements ¶
func (db *AgbotPostgresqlDB) FindAgreements(filters []persistence.AFilter, protocol string) ([]persistence.Agreement, error)
Retrieve all agreements from the database and filter them out based on the input filters.
func (*AgbotPostgresqlDB) FindPartitions ¶
func (db *AgbotPostgresqlDB) FindPartitions() ([]string, error)
Locate all the partitions currently found in the database, for all agbots.
func (*AgbotPostgresqlDB) FindSingleAgreementByAgreementId ¶
func (db *AgbotPostgresqlDB) FindSingleAgreementByAgreementId(agreementId string, protocol string, filters []persistence.AFilter) (*persistence.Agreement, error)
func (*AgbotPostgresqlDB) FindSingleAgreementByAgreementIdAllProtocols ¶
func (db *AgbotPostgresqlDB) FindSingleAgreementByAgreementIdAllProtocols(agreementid string, protocols []string, filters []persistence.AFilter) (*persistence.Agreement, error)
func (*AgbotPostgresqlDB) FindSingleWorkloadUsageByDeviceAndPolicyName ¶
func (db *AgbotPostgresqlDB) FindSingleWorkloadUsageByDeviceAndPolicyName(deviceid string, policyName string) (*persistence.WorkloadUsage, error)
func (*AgbotPostgresqlDB) FindWorkloadUsages ¶
func (db *AgbotPostgresqlDB) FindWorkloadUsages(filters []persistence.WUFilter) ([]persistence.WorkloadUsage, error)
func (*AgbotPostgresqlDB) GetAgreementCount ¶
func (db *AgbotPostgresqlDB) GetAgreementCount(partition string) (int64, int64, error)
func (*AgbotPostgresqlDB) GetAgreementPartitionMove ¶
func (db *AgbotPostgresqlDB) GetAgreementPartitionMove(fromPartition string, toPartition string) string
The partition table name replacement scheme used in this function is slightly different from the others above.
func (*AgbotPostgresqlDB) GetAgreementPartitionTableCount ¶
func (db *AgbotPostgresqlDB) GetAgreementPartitionTableCount(partition string) string
func (*AgbotPostgresqlDB) GetAgreementPartitionTableDrop ¶
func (db *AgbotPostgresqlDB) GetAgreementPartitionTableDrop(partition string) string
func (*AgbotPostgresqlDB) GetAgreementPartitionTableExists ¶
func (db *AgbotPostgresqlDB) GetAgreementPartitionTableExists(partition string) string
The SQL template used by this function is slightly different than the others and therefore does it's own calculation of how the table partition is substituted into the SQL. The difference is in the required use of single quotes.
func (*AgbotPostgresqlDB) GetAgreementPartitionTableName ¶
func (db *AgbotPostgresqlDB) GetAgreementPartitionTableName(partition string) string
func (*AgbotPostgresqlDB) GetPartitionOwner ¶
func (db *AgbotPostgresqlDB) GetPartitionOwner(id string) (string, error)
Retrieve the partition owner for a given partition.
func (*AgbotPostgresqlDB) GetPrimaryAgreementPartitionTableCreate ¶
func (db *AgbotPostgresqlDB) GetPrimaryAgreementPartitionTableCreate() string
func (*AgbotPostgresqlDB) GetPrimaryAgreementPartitionTableIndexCreate ¶
func (db *AgbotPostgresqlDB) GetPrimaryAgreementPartitionTableIndexCreate() string
func (*AgbotPostgresqlDB) GetPrimaryWorkloadUsagePartitionTableCreate ¶
func (db *AgbotPostgresqlDB) GetPrimaryWorkloadUsagePartitionTableCreate() string
func (*AgbotPostgresqlDB) GetPrimaryWorkloadUsagePartitionTableIndexCreate ¶
func (db *AgbotPostgresqlDB) GetPrimaryWorkloadUsagePartitionTableIndexCreate() string
func (*AgbotPostgresqlDB) GetWorkloadUsagePartitionMove ¶
func (db *AgbotPostgresqlDB) GetWorkloadUsagePartitionMove(fromPartition string, toPartition string) string
The partition table name replacement scheme used in this function is slightly different from the others above.
func (*AgbotPostgresqlDB) GetWorkloadUsagePartitionTableDrop ¶
func (db *AgbotPostgresqlDB) GetWorkloadUsagePartitionTableDrop(partition string) string
func (*AgbotPostgresqlDB) GetWorkloadUsagePartitionTableExists ¶
func (db *AgbotPostgresqlDB) GetWorkloadUsagePartitionTableExists(partition string) string
The SQL template used by this function is slightly different than the others and therefore does it's own calculation of how the table partition is substituted into the SQL. The difference is in the required use of single quotes.
func (*AgbotPostgresqlDB) GetWorkloadUsagePartitionTableName ¶
func (db *AgbotPostgresqlDB) GetWorkloadUsagePartitionTableName(partition string) string
func (*AgbotPostgresqlDB) GetWorkloadUsagePartitionUsageTableCount ¶
func (db *AgbotPostgresqlDB) GetWorkloadUsagePartitionUsageTableCount(partition string) string
func (*AgbotPostgresqlDB) GetWorkloadUsagesCount ¶
func (db *AgbotPostgresqlDB) GetWorkloadUsagesCount(partition string) (int64, error)
The partition table name replacement scheme used in this function is slightly different from the others above.
func (*AgbotPostgresqlDB) HeartbeatPartition ¶
func (db *AgbotPostgresqlDB) HeartbeatPartition() error
Update the hearbeat for our partition.
func (*AgbotPostgresqlDB) Initialize ¶
func (db *AgbotPostgresqlDB) Initialize(cfg *config.HorizonConfig) error
This function is called by the anax main to allow the configured database a chance to initialize itself. This function is called every time the agbot starts, so it has to handle the following cases: - Nothing exists in the database - The database contains structures with schema that are not at the latest version - The database is completely up to date WRT the schemas
func (*AgbotPostgresqlDB) MeteringNotification ¶
func (db *AgbotPostgresqlDB) MeteringNotification(agreementid string, protocol string, mn string) (*persistence.Agreement, error)
func (*AgbotPostgresqlDB) MovePartition ¶
func (db *AgbotPostgresqlDB) MovePartition(timeout uint64) error
Move all records from one partition to another if there is a stale or unowned partition in the database.
func (*AgbotPostgresqlDB) NewWorkloadUsage ¶
func (*AgbotPostgresqlDB) PrimaryPartition ¶
func (db *AgbotPostgresqlDB) PrimaryPartition() string
func (*AgbotPostgresqlDB) QuiescePartition ¶
func (db *AgbotPostgresqlDB) QuiescePartition() error
Quiesce our partition.
func (*AgbotPostgresqlDB) SingleAgreementUpdate ¶
func (db *AgbotPostgresqlDB) SingleAgreementUpdate(agreementid string, protocol string, fn func(persistence.Agreement) *persistence.Agreement) (*persistence.Agreement, error)
This function is used by all functions that want to change something in the database. It first locates the agreement to be updated (the query is done in it's own transaction), then calls the input function to update the agreement in memory, and finally calls wrapTransaction to start a transaction that will actually perform the update.
func (*AgbotPostgresqlDB) SingleWorkloadUsageUpdate ¶
func (db *AgbotPostgresqlDB) SingleWorkloadUsageUpdate(deviceid string, policyName string, fn func(persistence.WorkloadUsage) *persistence.WorkloadUsage) (*persistence.WorkloadUsage, error)
func (*AgbotPostgresqlDB) String ¶
func (db *AgbotPostgresqlDB) String() string
func (*AgbotPostgresqlDB) UpdatePendingUpgrade ¶
func (db *AgbotPostgresqlDB) UpdatePendingUpgrade(deviceid string, policyName string) (*persistence.WorkloadUsage, error)
func (*AgbotPostgresqlDB) UpdatePolicy ¶
func (db *AgbotPostgresqlDB) UpdatePolicy(deviceid string, policyName string, pol string) (*persistence.WorkloadUsage, error)
func (*AgbotPostgresqlDB) UpdatePriority ¶
func (db *AgbotPostgresqlDB) UpdatePriority(deviceid string, policyName string, priority int, retryDurationS int, verifiedDurationS int, agid string) (*persistence.WorkloadUsage, error)
func (*AgbotPostgresqlDB) UpdateRetryCount ¶
func (db *AgbotPostgresqlDB) UpdateRetryCount(deviceid string, policyName string, retryCount int, agid string) (*persistence.WorkloadUsage, error)
func (*AgbotPostgresqlDB) UpdateWUAgreementId ¶
func (db *AgbotPostgresqlDB) UpdateWUAgreementId(deviceid string, policyName string, agid string, protocol string) (*persistence.WorkloadUsage, error)
Updating the agreement id in the existing record is easy. However, the record might be in the wrong partition. It is possible that the agbot was restarted with a new primary partition, and then the agreement that was using this record was cancelled and moved to the new primary partition. If that's the case, we need to mkae sure the workload usage record gets moved to the new partition also. This is where that will happen.
Maybe you're asking yourself, why dont we just delete the workload usage record because it will get recreated in the new primary partition. The whole point of this record is that it retains state about which workload priority is being used in the agreement, which is what needs to be retained from one agreement to the next.
func (*AgbotPostgresqlDB) VerifyPartitions ¶
func (db *AgbotPostgresqlDB) VerifyPartitions(partitions []string) ([]string, error)
If any partition is owned by this agbot where the table is missing for any of the persisted objects, then remove that partition from the database.
type SchemaUpdate ¶
type SchemaUpdate struct {
// contains filtered or unexported fields
}