Documentation
¶
Index ¶
- Constants
- func ClassifyMirrorTopics(mirrors []MirrorTopic) (topicNames []string, inactiveTopics []string)
- func CountActiveMirrorTopics(mirrors []MirrorTopic) int
- func GetActiveTopicsWithZeroLag(mirrors []MirrorTopic) []string
- func HasActiveTopicsWithNonZeroLag(mirrors []MirrorTopic) bool
- type ClusterLink
- type Config
- type ConfigAlteration
- type ConfluentCloudService
- func (s *ConfluentCloudService) AlterConfigs(ctx context.Context, config Config, alterations []ConfigAlteration) error
- func (s *ConfluentCloudService) GetClusterLink(ctx context.Context, config Config) (*ClusterLink, error)
- func (s *ConfluentCloudService) ListConfigs(ctx context.Context, config Config) (map[string]string, error)
- func (s *ConfluentCloudService) ListMirrorTopics(ctx context.Context, config Config) ([]MirrorTopic, error)
- func (s *ConfluentCloudService) PromoteMirrorTopics(ctx context.Context, config Config, topicNames []string) (*PromoteMirrorTopicsResponse, error)
- func (s *ConfluentCloudService) ValidateTopics(topics []string, clusterLinkTopics []string) error
- type HTTPClient
- type MirrorLag
- type MirrorTopic
- type PromoteMirrorTopicsResponse
- type Service
Constants ¶
const ( // Mirror topic status constants MirrorStatusActive = "ACTIVE" // MirrorStatusStopped is the terminal state once promotion/failover has // completed and the topic is a standalone writable topic. Promotion is // confirmed by waiting for this state; any other (transient) status is // treated as "not done yet". MirrorStatusStopped = "STOPPED" )
const ( OperationSet = "SET" OperationDelete = "DELETE" )
Operation values accepted by AlterConfigs. They mirror the Confluent REST v3 batch-alter conventions: SET writes the value, DELETE clears it back to the server-side default.
Variables ¶
This section is empty.
Functions ¶
func ClassifyMirrorTopics ¶
func ClassifyMirrorTopics(mirrors []MirrorTopic) (topicNames []string, inactiveTopics []string)
func CountActiveMirrorTopics ¶
func CountActiveMirrorTopics(mirrors []MirrorTopic) int
CountActiveMirrorTopics returns the count of active mirror topics
func GetActiveTopicsWithZeroLag ¶
func GetActiveTopicsWithZeroLag(mirrors []MirrorTopic) []string
GetActiveTopicsWithZeroLag returns topic names that are active and have zero lag across all partitions
func HasActiveTopicsWithNonZeroLag ¶
func HasActiveTopicsWithNonZeroLag(mirrors []MirrorTopic) bool
HasActiveTopicsWithNonZeroLag checks if there are any active topics with non-zero lag
Types ¶
type ClusterLink ¶ added in v0.8.0
type ClusterLink struct {
LinkName string `json:"link_name"`
LinkID string `json:"link_id"`
ClusterID string `json:"cluster_id"`
SourceClusterID string `json:"source_cluster_id"`
LinkState string `json:"link_state"`
LinkError string `json:"link_error,omitempty"`
}
ClusterLink describes a Confluent Cloud cluster link as returned by GET /kafka/v3/clusters/{cluster_id}/links/{link_name}.
type Config ¶
type Config struct {
RestEndpoint string
ClusterID string
LinkName string
APIKey string
APISecret string
Topics []string
}
Config holds cluster link configuration
type ConfigAlteration ¶ added in v0.8.1
type ConfigAlteration struct {
Name string `json:"name"`
Value string `json:"value"`
Operation string `json:"operation"`
}
ConfigAlteration is one entry in a batch :alter request body. Operation must be OperationSet or OperationDelete; Value is ignored for DELETE.
type ConfluentCloudService ¶
type ConfluentCloudService struct {
// contains filtered or unexported fields
}
ConfluentCloudService implements cluster link operations using Confluent Cloud REST API
func NewConfluentCloudService ¶
func NewConfluentCloudService(httpClient HTTPClient) *ConfluentCloudService
NewConfluentCloudService creates a new cluster link service
func (*ConfluentCloudService) AlterConfigs ¶ added in v0.8.1
func (s *ConfluentCloudService) AlterConfigs(ctx context.Context, config Config, alterations []ConfigAlteration) error
AlterConfigs applies a batch of cluster link config alterations.
The Confluent Platform Kafka REST v3 API exposes per-config endpoints rather than a batch :alter resource (verified against CP 8.x where POST /configs:alter returns 405). SET maps to PUT /configs/{name} with {"value": ...}, DELETE maps to DELETE /configs/{name}. We iterate the batch client-side to provide a stable interface above the version-dependent shape — first error short-circuits and is returned.
NOT atomic: alterations before the failing index are already persisted server-side. The returned error does not identify the partition between applied and skipped entries. See the Service interface doc.
Empty alterations short-circuit without a network call. 404 / 401 / 403 translate to actionable messages matching GetClusterLink's style.
func (*ConfluentCloudService) GetClusterLink ¶ added in v0.8.0
func (s *ConfluentCloudService) GetClusterLink(ctx context.Context, config Config) (*ClusterLink, error)
GetClusterLink fetches the cluster link resource. Translates common failure statuses (404, 401/403) into user-facing messages so callers can surface actionable errors to the CLI.
func (*ConfluentCloudService) ListConfigs ¶
func (s *ConfluentCloudService) ListConfigs(ctx context.Context, config Config) (map[string]string, error)
ListConfigs retrieves cluster link configurations
func (*ConfluentCloudService) ListMirrorTopics ¶
func (s *ConfluentCloudService) ListMirrorTopics(ctx context.Context, config Config) ([]MirrorTopic, error)
func (*ConfluentCloudService) PromoteMirrorTopics ¶
func (s *ConfluentCloudService) PromoteMirrorTopics(ctx context.Context, config Config, topicNames []string) (*PromoteMirrorTopicsResponse, error)
PromoteMirrorTopics promotes the specified mirror topics
func (*ConfluentCloudService) ValidateTopics ¶
func (s *ConfluentCloudService) ValidateTopics(topics []string, clusterLinkTopics []string) error
ValidateTopics validates that all specified topics exist in cluster link
type HTTPClient ¶
HTTPClient interface for HTTP operations
type MirrorTopic ¶
type PromoteMirrorTopicsResponse ¶
type PromoteMirrorTopicsResponse struct {
Data []struct {
MirrorTopicName string `json:"mirror_topic_name"`
ErrorMessage string `json:"error_message,omitempty"`
ErrorCode int `json:"error_code,omitempty"`
} `json:"data"`
}
PromoteMirrorTopicsResponse represents the response from promoting mirror topics
type Service ¶
type Service interface {
GetClusterLink(ctx context.Context, config Config) (*ClusterLink, error)
ListMirrorTopics(ctx context.Context, config Config) ([]MirrorTopic, error)
ListConfigs(ctx context.Context, config Config) (map[string]string, error)
ValidateTopics(topics []string, clusterLinkTopics []string) error
PromoteMirrorTopics(ctx context.Context, config Config, topicNames []string) (*PromoteMirrorTopicsResponse, error)
// AlterConfigs applies the given alterations to the cluster link's configs.
//
// IMPORTANT: this method is NOT atomic across multiple alterations. The
// implementation iterates the slice and issues one network call per entry,
// short-circuiting on the first error. On mid-batch failure, alterations
// before the failing index are already persisted server-side; alterations
// at and after the failing index are NOT applied. The returned error does
// not identify which entries succeeded — callers that need batch
// atomicity must implement compensation themselves, or call this method
// with a single alteration at a time.
AlterConfigs(ctx context.Context, config Config, alterations []ConfigAlteration) error
}
Service defines cluster link operations