bastion

package
v0.6.10 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(
	registry funcie.ApplicationRegistry,
	appClient ApplicationClient,
	consumer funcie.Consumer,
	hostTranslator HostTranslator,
) transports.MessageHandler

NewHandler creates a new Handler that can register and unregister applications and forward requests.

Types

type ApplicationClient

type ApplicationClient interface {
	// ProcessRequest sends a request from the server bastion to the client.
	ProcessRequest(ctx context.Context, application funcie.Application, request *funcie.Message) (*funcie.Response, error)
}

ApplicationClient allows communication between the client bastion and the client application.

func NewHTTPApplicationClient

func NewHTTPApplicationClient(client *http.Client) ApplicationClient

NewHTTPApplicationClient creates a new ApplicationClient that uses the given HttpClient to communicate with the client application.

type Config

type Config struct {
	// RedisAddress is the address of the Redis server.
	RedisAddress string `json:"redisAddress"`
	// ListenAddress is the address to listen on for client requests.
	ListenAddress string `json:"listenAddress"`
	// BaseChannelName is the base name of the Redis channel keys to use.
	BaseChannelName string `json:"baseChannelName"`
}

func NewConfig

func NewConfig() *Config

NewConfig creates a new Config with no values set.

func NewConfigFromEnvironment

func NewConfigFromEnvironment() *Config

NewConfigFromEnvironment creates a new Config from environment variables. The following environment variables are used:

FUNCIE_REDIS_ADDRESS (required)
FUNCIE_LISTEN_ADDRESS (required)
FUNCIE_BASE_CHANNEL_NAME (optional)

type HostTranslator added in v0.1.0

type HostTranslator interface {
	// IsHostTranslationRequired indicates whether we need to translate localhost requests to an alternative host.
	// For example, if we're running in MacOS, we need to translate localhost to host.docker.internal.
	IsHostTranslationRequired(ctx context.Context) (bool, error)
	// TranslateLocalHostToResolvedHost translates a local host (...such as localhost) to the resolved host.
	// For example, if we're running in MacOS, this could translate localhost to host.docker.internal.
	// If the host does not need to be translated, the original host is returned.
	// This also handles scenarios where the host is an IP address, such as 0.0.0.0 or 127.0.0.1.
	TranslateLocalHostToResolvedHost(ctx context.Context, host string) (string, error)
}

HostTranslator is an interface for translating hosts from an entered host to a resolved host. For example, this could translate local or unspecified IPs to the docker host when running in MacOS.

func NewDockerHostTranslator added in v0.1.0

func NewDockerHostTranslator() HostTranslator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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