hosts

package
v0.0.0-...-0cd5192 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHostNotFound = errors.New("host not found")

Functions

func WithBaseHostname

func WithBaseHostname(baseHostname string) serviceOption

WithBaseHostname provides a base hostname, to use when generating hostnames.

func WithDatabase

func WithDatabase(db Database) serviceOption

WithDatabase provides a database, which is used for storing hosts data.

func WithLogger

func WithLogger(logger *zap.Logger) serviceOption

WithLogger provides a logger, which is used for logging hosts management events.

Types

type Database

type Database interface {
	StoreHosts(ctx context.Context, hosts ...Host) error
	StoreHTTPLogEntry(ctx context.Context, entry HTTPLogEntry) error
	FindHostByID(ctx context.Context, hostID ulid.ULID) (Host, error)
	FindHostByHostname(ctx context.Context, hostname string) (Host, error)
	ListHTTPLogEntries(ctx context.Context, params ListHTTPLogEntriesParams) ([]HTTPLogEntry, error)
}

type HTTPLogEntry

type HTTPLogEntry struct {
	ID          ulid.ULID
	HostID      ulid.ULID
	Request     *http.Request
	Response    *http.Response
	RawRequest  []byte
	RawResponse []byte
}

type Host

type Host struct {
	ID       ulid.ULID
	Hostname string
}

type ListHTTPLogEntriesParams

type ListHTTPLogEntriesParams struct {
	HostIDs []ulid.ULID
}

type Service

type Service interface {
	CreateHosts(ctx context.Context, amount int) ([]Host, error)
	FindHostByID(ctx context.Context, hostID ulid.ULID) (Host, error)
	StoreHTTPLogEntry(ctx context.Context, params StoreHTTPLogEntryParams) error
	ListHTTPLogEntries(ctx context.Context, params ListHTTPLogEntriesParams) ([]HTTPLogEntry, error)
}

func NewService

func NewService(opts ...serviceOption) Service

type StoreHTTPLogEntryParams

type StoreHTTPLogEntryParams struct {
	Request  *http.Request
	Response *http.Response
}

Jump to

Keyboard shortcuts

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