serverchecker

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package serverchecker contains the functions to check if a cloud server is ready.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockSSHClient added in v0.1.2

type MockSSHClient struct {
	ConnectFunc     func() error
	CloseFunc       func() error
	ExecCommandFunc func(string) (string, error)
}

func (*MockSSHClient) Close added in v0.1.2

func (m *MockSSHClient) Close() error

func (*MockSSHClient) Connect added in v0.1.2

func (m *MockSSHClient) Connect() error

func (*MockSSHClient) ExecCommand added in v0.1.2

func (m *MockSSHClient) ExecCommand(cmd string) (string, error)

type RealSSHClient added in v0.1.2

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

func (*RealSSHClient) Close added in v0.1.2

func (r *RealSSHClient) Close() error

func (*RealSSHClient) Connect added in v0.1.2

func (r *RealSSHClient) Connect() error

func (*RealSSHClient) ExecCommand added in v0.1.2

func (r *RealSSHClient) ExecCommand(cmd string) (string, error)

type SSHClient added in v0.1.2

type SSHClient interface {
	Connect() error
	Close() error
	ExecCommand(cmd string) (string, error)
}

SSHClient interface abstracts SSH operations

type ServerChecker

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

func NewServerChecker

func NewServerChecker(host string, user string, keyPath string, timeout time.Duration, attempts int) (*ServerChecker, error)

func (*ServerChecker) Check added in v0.1.2

func (sc *ServerChecker) Check() (bool, error)

Check verifies if the server is ready This is now a wrapper around CheckWithContext using the server's timeout

func (*ServerChecker) CheckWithContext added in v0.1.2

func (sc *ServerChecker) CheckWithContext(ctx context.Context) (bool, error)

CheckWithContext verifies if the server is ready using the provided context Returns true if the server is ready, false otherwise If an error occurs during checking, it returns false and the error

type ServerResult

type ServerResult struct {
	Server *types.Server
	Ready  bool
	Error  error
}

func CheckServers

func CheckServers(servers []*types.Server, logger *slog.Logger, timeout time.Duration, attempts int) ([]ServerResult, error)

Jump to

Keyboard shortcuts

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