diff --git a/services/indexer/indexer.gen.go b/services/indexer/indexer.gen.go index 23e345b9..d9280317 100644 --- a/services/indexer/indexer.gen.go +++ b/services/indexer/indexer.gen.go @@ -1,4 +1,4 @@ -// sequence-indexer v0.4.0 12ecb31178000c1165150b0ac0f3a304ccc5a88d +// sequence-indexer v0.4.0 4d157093ab69a43b01dc0721f28095acc32d3bd5 // -- // Code generated by webrpc-gen@v0.31.2 with golang generator. DO NOT EDIT. // @@ -33,13 +33,20 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "12ecb31178000c1165150b0ac0f3a304ccc5a88d" + return "4d157093ab69a43b01dc0721f28095acc32d3bd5" } // // Client interface // +type AdminClient interface { + // GetBackupProgress – returns the progress of a backup identified by backupId. + GetBackupProgress(ctx context.Context, backupId string) (*BackupProgress, error) + // StartBackup – starts bond DB backup in background. Only one backup at a time. Default mode incremental. + StartBackup(ctx context.Context, mode *BackupMode) (string, error) +} + type IndexerClient interface { AddWebhookListener(ctx context.Context, url string, filters *EventFilter, projectId *uint64) (bool, *WebhookListener, error) // Fetches a single receipt and then will stop the subscription @@ -278,6 +285,106 @@ type Asset struct { UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` } +type BackupMode uint8 + +const ( + BackupMode_INCREMENTAL BackupMode = 0 + BackupMode_COMPLETE BackupMode = 1 +) + +var BackupMode_name = map[uint8]string{ + 0: "INCREMENTAL", + 1: "COMPLETE", +} + +var BackupMode_value = map[string]uint8{ + "INCREMENTAL": 0, + "COMPLETE": 1, +} + +func (x BackupMode) String() string { + return BackupMode_name[uint8(x)] +} + +func (x BackupMode) MarshalText() ([]byte, error) { + return []byte(BackupMode_name[uint8(x)]), nil +} + +func (x *BackupMode) UnmarshalText(b []byte) error { + *x = BackupMode(BackupMode_value[string(b)]) + return nil +} + +func (x *BackupMode) Is(values ...BackupMode) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + +type BackupProgress struct { + ID string `json:"id"` + Status BackupStatus `json:"status"` + Mode BackupMode `json:"mode"` + StartedAt time.Time `json:"startedAt"` + CompletedAt *time.Time `json:"completedAt"` + FilesDone int `json:"filesDone"` + FilesTotal int `json:"filesTotal"` + BytesDone int64 `json:"bytesDone"` + BytesTotal int64 `json:"bytesTotal"` + Error *string `json:"error"` +} + +type BackupStatus uint8 + +const ( + BackupStatus_RUNNING BackupStatus = 0 + BackupStatus_COMPLETED BackupStatus = 1 + BackupStatus_FAILED BackupStatus = 2 +) + +var BackupStatus_name = map[uint8]string{ + 0: "RUNNING", + 1: "COMPLETED", + 2: "FAILED", +} + +var BackupStatus_value = map[string]uint8{ + "RUNNING": 0, + "COMPLETED": 1, + "FAILED": 2, +} + +func (x BackupStatus) String() string { + return BackupStatus_name[uint8(x)] +} + +func (x BackupStatus) MarshalText() ([]byte, error) { + return []byte(BackupStatus_name[uint8(x)]), nil +} + +func (x *BackupStatus) UnmarshalText(b []byte) error { + *x = BackupStatus(BackupStatus_value[string(b)]) + return nil +} + +func (x *BackupStatus) Is(values ...BackupStatus) bool { + if x == nil { + return false + } + for _, v := range values { + if *x == v { + return true + } + } + return false +} + type BloomStats struct { HitRatio string `json:"hitRatio"` FalsePositivesPercent string `json:"falsePositivesPercent"` @@ -985,6 +1092,7 @@ type TokenBalancesByContractFilter struct { ContractAddresses []prototyp.Hash `json:"contractAddresses"` AccountAddresses []prototyp.Hash `json:"accountAddresses"` ContractStatus ContractVerificationStatus `json:"contractStatus"` + TokenIDs []prototyp.BigInt `json:"tokenIDs"` } type TokenBalancesFilter struct { @@ -995,6 +1103,7 @@ type TokenBalancesFilter struct { ContractBlacklist []prototyp.Hash `json:"contractBlacklist"` OmitNativeBalances bool `json:"omitNativeBalances,omitempty"` OmitPrices bool `json:"omitPrices,omitempty"` + TokenIDs []prototyp.BigInt `json:"tokenIDs"` } // Token History @@ -1288,22 +1397,80 @@ type WALWriterRuntimeStatus struct { } type WebhookListener struct { - ID uint64 `json:"id" db:"id"` - ProjectID uint64 `json:"projectID" db:"project_id"` - Url string `json:"url" db:"url"` - Filters *EventFilter `json:"filters" db:"filters"` - Name string `json:"name" db:"name"` - UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` - Active bool `json:"active" db:"active"` + ID uint64 `json:"id" db:"id"` + ProjectID uint64 `json:"projectID" db:"project_id"` + Url string `json:"url" db:"url"` + Filters *EventFilter `json:"filters" db:"filters"` + Name string `json:"name" db:"name"` + UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` + Active bool `json:"active" db:"active"` + DisabledAt *time.Time `json:"disabledAt" db:"disabled_at"` + DisabledReason *string `json:"disabledReason" db:"disabled_reason"` } // // Client // +const AdminPathPrefix = "/rpc/Admin/" const IndexerPathPrefix = "/rpc/Indexer/" const IndexerGatewayPathPrefix = "/rpc/IndexerGateway/" +type adminClient struct { + client HTTPClient + urls [2]string +} + +func NewAdminClient(addr string, client HTTPClient) AdminClient { + prefix := urlBase(addr) + AdminPathPrefix + urls := [2]string{ + prefix + "GetBackupProgress", + prefix + "StartBackup", + } + return &adminClient{ + client: client, + urls: urls, + } +} + +func (c *adminClient) GetBackupProgress(ctx context.Context, backupId string) (*BackupProgress, error) { + in := struct { + Arg0 string `json:"backupId"` + }{backupId} + out := struct { + Ret0 *BackupProgress `json:"progress"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[0], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + +func (c *adminClient) StartBackup(ctx context.Context, mode *BackupMode) (string, error) { + in := struct { + Arg0 *BackupMode `json:"mode"` + }{mode} + out := struct { + Ret0 string `json:"backupId"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[1], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + type indexerClient struct { client HTTPClient urls [36]string