Help us shape the future of Go! Take the 2026 Go Developer Survey

endpointstrategy

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package endpointstrategy formats and parses the resource URLs that LocalStack's *_ENDPOINT_STRATEGY options select (SQS queue URLs, OpenSearch domain endpoints, AppSync GraphQL URIs, ECR registry hosts). The zero value of every strategy keeps the pre-existing Gopherstack URL shape.

Index

Constants

View Source
const LocalDomain = "localhost.localstack.cloud"

LocalDomain is the public DNS zone that resolves every subdomain to loopback.

Variables

View Source
var ErrInvalidStrategy = errors.New("invalid endpoint strategy")

ErrInvalidStrategy is returned for an unknown or unsupported strategy value.

Functions

func ECRRegistryHost

func ECRRegistryHost(strategy, hostPort, account, region string) string

ECRRegistryHost formats the host part of a repository URI. An empty strategy returns "".

func GraphQLURI

func GraphQLURI(strategy, base, apiID string) string

GraphQLURI formats an AppSync GraphQL endpoint. base is the gateway URL (scheme://host:port); an empty strategy keeps base/v1/apis/<id>/graphql.

func IsSQSQueuePath

func IsSQSQueuePath(path string) bool

IsSQSQueuePath reports whether path has a queue-URL shape (/acct/name or /queue/region/acct/name).

func OpenSearchEndpoint

func OpenSearchEndpoint(strategy, hostPort, engine, region, account, name string) string

OpenSearchEndpoint formats a domain endpoint (no scheme). engine is "opensearch" or "es". An empty strategy keeps the AWS-style search-<name>-<account>.<region>.es.amazonaws.com host.

func ParseGraphQLRequest

func ParseGraphQLRequest(host, path string) (string, string, bool)

ParseGraphQLRequest returns the API id and the sub-path below the graphql endpoint for a strategy-addressed request, or ok=false.

func SQSQueueURL

func SQSQueueURL(strategy, scheme, requestHost, region, account, name string) string

SQSQueueURL formats a queue URL. requestHost is the host:port the client used; an empty strategy or "off" keeps the Gopherstack shape scheme://host/account/name.

func SQSRegion

func SQSRegion(host, path string) string

SQSRegion returns the region encoded in an inbound queue request (host or path), or "".

Types

type Config

type Config struct {
	SQS        string
	OpenSearch string
	GraphQL    string
	ECR        string
	// OpenSearchMultiCluster is "false" to share one index store across domains; anything else isolates per domain.
	OpenSearchMultiCluster string
	// OpenSearchCustomBackend is the base URL data-plane requests are proxied to; empty uses the built-in engine.
	OpenSearchCustomBackend string
	// HostPort is the gateway address (host:port) used when a strategy needs one.
	HostPort string
}

Config carries the selected strategies and the gateway host:port.

func From

func From(cfg any) Config

From extracts the Config from an app config, or the zero Config.

func (Config) CustomBackendURL

func (c Config) CustomBackendURL() (*url.URL, error)

CustomBackendURL parses OPENSEARCH_CUSTOM_BACKEND; a nil URL means unset.

func (Config) SharedOpenSearchCluster

func (c Config) SharedOpenSearchCluster() bool

SharedOpenSearchCluster reports whether OPENSEARCH_MULTI_CLUSTER=false asks for one shared index store.

func (Config) Validate

func (c Config) Validate() error

Validate checks every strategy value; "port" for OpenSearch is rejected because Gopherstack serves every resource from the one gateway listener.

type Flags

type Flags struct {
	SQS string `` //nolint:lll // config struct tags are intentionally verbose
	/* 174-byte string literal not displayed */
	OpenSearch string `` //nolint:lll // config struct tags are intentionally verbose
	/* 178-byte string literal not displayed */
	GraphQL string `` //nolint:lll // config struct tags are intentionally verbose
	/* 163-byte string literal not displayed */
	// OpenSearchMultiCluster and OpenSearchCustomBackend are opt-in LocalStack-compatible options.
	OpenSearchMultiCluster string `` //nolint:lll // config struct tags are intentionally verbose
	/* 182-byte string literal not displayed */
	OpenSearchCustomBackend string `` //nolint:lll // config struct tags are intentionally verbose
	/* 191-byte string literal not displayed */
	ECR string `` //nolint:lll // config struct tags are intentionally verbose
	/* 150-byte string literal not displayed */
}

Flags are the user-selected strategies (CLI flags and LocalStack-compatible env vars).

func (Flags) Config

func (f Flags) Config(hostPort string) Config

Config combines the flags with the gateway address.

type OpenSearchRequest

type OpenSearchRequest struct {
	Region string
	Domain string
	// Rest is the request path below the domain, starting with "/" or empty.
	Rest string
}

OpenSearchRequest is a data-plane request addressed through a strategy endpoint.

func ParseOpenSearchRequest

func ParseOpenSearchRequest(host, path string) (OpenSearchRequest, bool)

ParseOpenSearchRequest recognises <domain>.<region>.<engine>.localhost.localstack.cloud hosts and /<engine>/<region>/<domain>/... paths.

type Provider

type Provider interface {
	EndpointStrategies() Config
}

Provider is implemented by the app config to expose Config to services.

Jump to

Keyboard shortcuts

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