client

package
v0.0.0-...-5abb786 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client es el cliente de bootstrap para etcd

func NewClient

func NewClient(myConfig *config.Config) (*Client, error)

NewClient crea un nuevo cliente de bootstrap

func (*Client) Bootstrap

func (c *Client) Bootstrap(ctx context.Context) error

Bootstrap realiza el proceso de bootstrap

func (*Client) CheckEtcdHealth

func (c *Client) CheckEtcdHealth(ctx context.Context, processID int, dataDir string) (*EtcdHealth, error)

CheckEtcdHealth performs a comprehensive health check on the etcd server

func (*Client) Close

func (c *Client) Close() error

Close cierra el cliente

func (*Client) Compact

func (c *Client) Compact(ctx context.Context, revision int64, physical bool) error

Compact performs logical compaction in etcd

func (*Client) EndpointsStatus

func (c *Client) EndpointsStatus(ctx context.Context) (map[string]interface{}, error)

EndpointsStatus returns status for all endpoints

func (*Client) GetCurrentRevision

func (c *Client) GetCurrentRevision(ctx context.Context) (int64, error)

GetCurrentRevision returns the current revision of the etcd cluster

func (*Client) GetDatabaseSize

func (c *Client) GetDatabaseSize(ctx context.Context) (int64, error)

GetDatabaseSize returns the size of the etcd database in bytes

func (*Client) GetLeader

func (c *Client) GetLeader(ctx context.Context) (interface{}, error)

GetLeader returns information about the current leader

func (*Client) GetMetrics

func (c *Client) GetMetrics(ctx context.Context) (map[string]interface{}, error)

GetMetrics returns basic metrics from etcd

func (*Client) GetStatus

func (c *Client) GetStatus(ctx context.Context) (*Status, error)

GetStatus verifica el estado actual del servidor etcd

func (*Client) ListAlarms

func (c *Client) ListAlarms(ctx context.Context) ([]string, error)

ListAlarms lists all alarms in the etcd cluster

func (*Client) MemberList

func (c *Client) MemberList(ctx context.Context) ([]interface{}, error)

MemberList returns list of members in the cluster

func (*Client) NeedsBootstrap

func (c *Client) NeedsBootstrap(ctx context.Context, pid int) (bool, error)

* /** NeedsBootstrap checks if the etcd cluster needs to be bootstrapped by performing several validation checks:

1. Verifies if the etcd process is running using the provided process ID 2. Checks if the etcd socket is available and accessible with retries 3. Validates that the socket is not blocked with retries 4. Confirms there is an elected leader in the cluster 5. If a root user is configured, verifies if it exists

Parameters:

  • ctx: Context for timeout/cancellation
  • pid: Process ID of the etcd server

Returns:

  • bool: true if bootstrap is needed, false otherwise
  • error: Error details if any check fails

The function will retry socket checks up to 5 times with 10 second delays between attempts. It uses context for proper timeout handling and cancellation support.

Common error cases: - Process not running - Socket unavailable after retries - Socket blocked after retries - No leader elected - Root user does not exist (when configured) - Authentication/connection errors

func (*Client) RestoreSnapshot

func (c *Client) RestoreSnapshot(ctx context.Context, opts RestoreOptions) error

RestoreSnapshot restores from a snapshot file

func (*Client) SaveSnapshot

func (c *Client) SaveSnapshot(ctx context.Context, filePath string) error

SaveSnapshot creates a snapshot of the etcd database

type EtcdHealth

type EtcdHealth struct {
	IsSocketAvailable bool
	IsSocketBlocked   bool
	ProcessRunning    bool
	DataValid         bool
	HasLeader         bool
	ErrorMessage      string
}

EtcdHealth contains information about the health status of etcd

type RestoreOptions

type RestoreOptions struct {
	SnapshotPath   string
	DataDir        string
	SkipHashCheck  bool
	Name           string
	ClusterToken   string
	InitialCluster string
}

RestoreOptions contains options for snapshot restore

type Status

type Status struct {
	IsRunning   bool `default:"false"`
	HasRootUser bool `default:"false"`
	AuthEnabled bool `default:"false"`
	MemberCount int
	IsLeader    bool `default:"false"`
	Version     string
}

Status representa el estado actual del servidor etcd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL