github.com/influxdata/influxdb/v2@v2.7.6/replication.go (about) 1 package influxdb 2 3 import ( 4 "fmt" 5 6 "github.com/influxdata/influxdb/v2/kit/platform" 7 "github.com/influxdata/influxdb/v2/kit/platform/errors" 8 ) 9 10 const ( 11 MinReplicationMaxQueueSizeBytes int64 = 33554430 // 32 MiB 12 DefaultReplicationMaxQueueSizeBytes = 2 * MinReplicationMaxQueueSizeBytes 13 DefaultReplicationMaxAge int64 = 604800 // 1 week, in seconds 14 ) 15 16 var ErrMaxQueueSizeTooSmall = errors.Error{ 17 Code: errors.EInvalid, 18 Msg: fmt.Sprintf("maxQueueSize too small, must be at least %d", MinReplicationMaxQueueSizeBytes), 19 } 20 21 // Replication contains all info about a replication that should be returned to users. 22 type Replication struct { 23 ID platform.ID `json:"id" db:"id"` 24 OrgID platform.ID `json:"orgID" db:"org_id"` 25 Name string `json:"name" db:"name"` 26 Description *string `json:"description,omitempty" db:"description"` 27 RemoteID platform.ID `json:"remoteID" db:"remote_id"` 28 LocalBucketID platform.ID `json:"localBucketID" db:"local_bucket_id"` 29 RemoteBucketID *platform.ID `json:"remoteBucketID" db:"remote_bucket_id"` 30 RemoteBucketName string `json:"RemoteBucketName" db:"remote_bucket_name"` 31 MaxQueueSizeBytes int64 `json:"maxQueueSizeBytes" db:"max_queue_size_bytes"` 32 CurrentQueueSizeBytes int64 `json:"currentQueueSizeBytes"` 33 RemainingBytesToBeSynced int64 `json:"remainingBytesToBeSynced"` 34 LatestResponseCode *int32 `json:"latestResponseCode,omitempty" db:"latest_response_code"` 35 LatestErrorMessage *string `json:"latestErrorMessage,omitempty" db:"latest_error_message"` 36 DropNonRetryableData bool `json:"dropNonRetryableData" db:"drop_non_retryable_data"` 37 MaxAgeSeconds int64 `json:"maxAgeSeconds" db:"max_age_seconds"` 38 } 39 40 // ReplicationListFilter is a selection filter for listing replications. 41 type ReplicationListFilter struct { 42 OrgID platform.ID 43 Name *string 44 RemoteID *platform.ID 45 LocalBucketID *platform.ID 46 } 47 48 // Replications is a collection of metadata about replications. 49 type Replications struct { 50 Replications []Replication `json:"replications"` 51 } 52 53 // TrackedReplication defines a replication stream which is currently being tracked via sqlite. 54 type TrackedReplication struct { 55 MaxQueueSizeBytes int64 56 MaxAgeSeconds int64 57 OrgID platform.ID 58 LocalBucketID platform.ID 59 } 60 61 // CreateReplicationRequest contains all info needed to establish a new replication 62 // to a remote InfluxDB bucket. 63 type CreateReplicationRequest struct { 64 OrgID platform.ID `json:"orgID"` 65 Name string `json:"name"` 66 Description *string `json:"description,omitempty"` 67 RemoteID platform.ID `json:"remoteID"` 68 LocalBucketID platform.ID `json:"localBucketID"` 69 RemoteBucketID platform.ID `json:"remoteBucketID"` 70 RemoteBucketName string `json:"remoteBucketName"` 71 MaxQueueSizeBytes int64 `json:"maxQueueSizeBytes,omitempty"` 72 DropNonRetryableData bool `json:"dropNonRetryableData,omitempty"` 73 MaxAgeSeconds int64 `json:"maxAgeSeconds,omitempty"` 74 } 75 76 func (r *CreateReplicationRequest) OK() error { 77 if r.MaxQueueSizeBytes < MinReplicationMaxQueueSizeBytes { 78 return &ErrMaxQueueSizeTooSmall 79 } 80 81 return nil 82 } 83 84 // UpdateReplicationRequest contains a partial update to existing info about a replication. 85 type UpdateReplicationRequest struct { 86 Name *string `json:"name,omitempty"` 87 Description *string `json:"description,omitempty"` 88 RemoteID *platform.ID `json:"remoteID,omitempty"` 89 RemoteBucketID *platform.ID `json:"remoteBucketID,omitempty"` 90 RemoteBucketName *string `json:"remoteBucketName,omitempty"` 91 MaxQueueSizeBytes *int64 `json:"maxQueueSizeBytes,omitempty"` 92 DropNonRetryableData *bool `json:"dropNonRetryableData,omitempty"` 93 MaxAgeSeconds *int64 `json:"maxAgeSeconds,omitempty"` 94 } 95 96 func (r *UpdateReplicationRequest) OK() error { 97 if r.MaxQueueSizeBytes == nil { 98 return nil 99 } 100 101 if *r.MaxQueueSizeBytes < MinReplicationMaxQueueSizeBytes { 102 return &ErrMaxQueueSizeTooSmall 103 } 104 105 return nil 106 } 107 108 // ReplicationHTTPConfig contains all info needed by a client to make HTTP requests against the 109 // remote bucket targeted by a replication. 110 type ReplicationHTTPConfig struct { 111 RemoteURL string `db:"remote_url"` 112 RemoteToken string `db:"remote_api_token"` 113 RemoteOrgID *platform.ID `db:"remote_org_id"` 114 AllowInsecureTLS bool `db:"allow_insecure_tls"` 115 RemoteBucketID *platform.ID `db:"remote_bucket_id"` 116 RemoteBucketName string `db:"remote_bucket_name"` 117 DropNonRetryableData bool `db:"drop_non_retryable_data"` 118 }