internalclient

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 20 Imported by: 8

Documentation

Index

Constants

View Source
const (
	DeviceUIDHeader = "X-Device-UID"
)

Variables

View Source
var (
	ErrConnectionFailed = errors.New("connection failed")
	ErrNotFound         = errors.New("not found")
	ErrForbidden        = errors.New("forbidden")
	ErrUnknown          = errors.New("unknown error")
)
View Source
var ErrRequestFailed = errors.New("request failed")

ErrRequestFailed is returned when an HTTP request fails to be executed.

Functions

func HasError added in v0.21.0

func HasError(resp *resty.Response, err error) error

HasError checks if there was an error in the HTTP response or if the provided error is not nil.

func WithAsynqWorker added in v0.17.0

func WithAsynqWorker(redisURI string) clientOption

Types

type Client

type Client interface {
	// contains filtered or unexported methods
}

func NewClient

func NewClient(cfg *Config, opts ...clientOption) (Client, error)

type Config added in v0.21.0

type Config struct {
	// RetryCount defines how many times the client should retry a request in case of failure.
	RetryCount int `env:"SHELLHUB_INTERNAL_HTTP_CLIENT_RETRY_COUNT,default=3"`
	// RetryWaitTime defines the wait time between retries.
	RetryWaitTime int `env:"SHELLHUB_INTERNAL_HTTP_CLIENT_RETRY_WAIT_TIME,default=5"`
	// RetryMaxWaitTime defines the maximum wait time between retries.
	RetryMaxWaitTime int `env:"SHELLHUB_INTERNAL_HTTP_CLIENT_RETRY_MAX_WAIT_TIME,default=20"`

	// APIBaseURL defines the base URL for the API service.
	APIBaseURL string `env:"SHELLHUB_INTERNAL_HTTP_CLIENT_API_BASE_URL,default=http://api:8080"`

	// EnterpriseBaseURL defines the base URL for enterprise endpoints (cloud component).
	EnterpriseBaseURL string `env:"SHELLHUB_INTERNAL_HTTP_CLIENT_ENTERPRISE_BASE_URL,default=http://cloud:8080"`
}

Config holds configuration options for the client.

func DefaultConfig added in v0.21.0

func DefaultConfig() (*Config, error)

DefaultConfig returns a Config struct with default values.

func NewConfigFromEnv added in v0.21.0

func NewConfigFromEnv() (*Config, error)

type Error added in v0.21.0

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error represents a custom error structure that includes an HTTP status code and a message.

func (*Error) Error added in v0.21.0

func (e *Error) Error() string

type LeveledLogger

type LeveledLogger struct {
	Logger *logrus.Logger
}

func (*LeveledLogger) Debugf added in v0.9.0

func (l *LeveledLogger) Debugf(msg string, keysAndValues ...any)

func (*LeveledLogger) Errorf added in v0.9.0

func (l *LeveledLogger) Errorf(msg string, keysAndValues ...any)

func (*LeveledLogger) Warnf added in v0.9.0

func (l *LeveledLogger) Warnf(msg string, keysAndValues ...any)

type WebEndpoint added in v0.20.0

type WebEndpoint struct {
	Address    string         `json:"address"`
	Namespace  string         `json:"namespace"`
	DeviceUID  string         `json:"device_uid"`
	Device     *models.Device `json:"device"`
	Host       string         `json:"host"`
	Port       int            `json:"port"`
	TimeToLive int            `json:"ttl"`
	TLS        WebEndpointTLS `json:"tls"`
	ExpiresIn  time.Time      `json:"expires_in"`
	CreatedAt  time.Time      `json:"time" bson:"time"`
}

type WebEndpointTLS added in v0.21.0

type WebEndpointTLS struct {
	Enabled bool   `json:"enabled"`
	Verify  bool   `json:"verify"`
	Domain  string `json:"domain"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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