Documentation
¶
Overview ¶
Package azurestoragevhost is a thin translation layer, not a storage service in its own right: it owns one dedicated listener that accepts virtual-hosted-style Azure Storage requests (Host: "{account}.blob.host:port", ".queue.", ".table.") and rewrites them into the path-style requests services/azureblob, services/azurequeue, and services/azuretable already serve (Host: anything, path "/{account}/...").
Why this exists: terraform-provider-azurerm's Blob/Queue/Table data-plane SDK (jackofallops/giovanni) hard-requires virtual-hosted-style URLs for every one of azurerm_storage_container/_blob/_queue/_table's post-create Read calls (AZURE.md section 10.8's M8 finding). gopherstack's M0-M2 Blob/Queue/Table services are path-style (Azurite-style, "{host}:{port}/{account}/...") -- an already-shipped, independently correct design this package does not change. Both styles now work simultaneously against the exact same backend state: creating a container through this listener and listing it through services/azureblob's own listener (or vice versa) see the same data, because this package never duplicates business logic -- it only rewrites the request, then calls the real service's own Handler() unchanged.
A structural constraint (not a design choice) is why Blob/Queue/Table must share one port here even though they keep three separate ports for path-style access: terraform-provider-azurerm's StorageDomainSuffix is a single shared string used to parse every one of these resources' account IDs back out of their endpoint URL, and Go's url.URL.Host always includes the port -- so one shared suffix can only match a host:port that is itself shared across all three services. See AZURE.md section 10.8 for the full derivation.
Index ¶
- Constants
- type ConfigProvider
- type Handler
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) StartWorker(ctx context.Context) error
- type Provider
- type Settings
- type StorageHandler
Constants ¶
const DefaultPort = 10010
DefaultPort is the fixed TCP port for the shared virtual-hosted-style storage listener. Unlike services/azureblob/azurequeue/azuretable's own fixed, protocol-conventional ports (10000/10001/10002, chosen to match Azurite's own defaults), this port has no real-Azure or Azurite equivalent -- it exists purely to satisfy terraform-provider-azurerm's data-plane SDK (jackofallops/giovanni), which requires Blob/Queue/Table to share one domain suffix (and therefore one port, since Go's url.URL.Host always includes the port) -- see AZURE.md section 10.8.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigProvider ¶
type ConfigProvider interface {
GetAzureStorageVHostSettings() Settings
}
ConfigProvider is a private interface to extract this service's configuration from the abstract AppContext Config, mirroring services/azureblob.ConfigProvider.
type Handler ¶
type Handler struct {
// Blob, Queue, and Table are the real services' handlers, wired in
// post-construction by cli.go's cross-service wiring (Init() runs
// before those services' own Init() calls are guaranteed to have
// happened, so these start nil and are set once all services exist).
Blob StorageHandler
Queue StorageHandler
Table StorageHandler
// Port is the TCP port StartWorker binds. Set from Settings at Init
// time; defaults to DefaultPort. Like services/azureblob, this is a
// single fixed port with no fallback pool -- StartWorker fails fast if
// it's unavailable.
Port int
// contains filtered or unexported fields
}
Handler is the Echo HTTP handler for the shared virtual-hosted-style Azure Storage listener. It holds no storage state of its own -- Blob, Queue, and Table each remain owned entirely by their own service; see the package doc comment.
func NewHandler ¶
func NewHandler() *Handler
NewHandler creates a new virtual-hosted storage Handler. Port defaults to DefaultPort; callers (typically provider.go) override it from Settings. Blob/Queue/Table are nil until wired by cli.go's cross-service wiring.
func (*Handler) ExtractOperation ¶
ExtractOperation delegates to the resolved service's own ExtractOperation where possible; metrics for requests that don't resolve to a known service/account are labeled "Unknown".
func (*Handler) ExtractResource ¶
ExtractResource returns the account name resolved from the Host header, for metrics labeling.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations returns no operations of its own: every request this listener accepts is delegated verbatim to Blob/Queue/Table's own Handler(), which is what actually reports the operation for metrics (see ExtractOperation).
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler function for the virtual-hosted storage listener: parse the account/service out of the Host header, rewrite the request path to the path-style shape the real service expects, and delegate to it unchanged.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority for this handler. Irrelevant in practice since RouteMatcher never matches; 0 (lowest) is the safe default.
func (*Handler) Reset ¶
func (h *Handler) Reset()
Reset is a no-op: this listener owns no state of its own to clear (see the package doc comment). Blob/Queue/Table each reset their own state independently when the POST /_gopherstack/reset endpoint calls Reset() on every registered service.
func (*Handler) RouteMatcher ¶
RouteMatcher exists only to satisfy service.Registerable's interface contract: like services/azureblob/azurequeue/azuretable, this runs on its own dedicated listener started by StartWorker, never on the shared AWS single-port Router.
func (*Handler) Shutdown ¶
Shutdown stops the dedicated virtual-hosted storage listener. Mirrors services/azureblob's Shutdown exactly.
func (*Handler) StartWorker ¶
StartWorker binds the dedicated virtual-hosted storage listener. Mirrors services/azureblob's StartWorker exactly (fixed port, fail-fast, no fallback pool) -- see that function's doc comment for the full rationale.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for the shared Azure Storage virtual-hosted-style listener. See handler.go's package doc comment for why this exists.
Like services/azureblob/azurequeue/azuretable, this does not register a RouteMatcher into the shared AWS single-port Router -- it runs on its own dedicated listener. It is registered in cli.go's getServiceProviders like every other provider; Blob/Queue/Table are wired into the returned Handler afterward, by cli.go's cross-service wiring (they aren't guaranteed to exist yet during Init()).
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the virtual-hosted storage Handler. The configured port (Settings.Port, default DefaultPort) is only recorded here; the actual TCP bind happens synchronously in Handler.StartWorker.
type Settings ¶
type Settings struct {
// Port is the fixed TCP port for the dedicated virtual-hosted-style
// storage listener. See handler.go's StartWorker for what happens when
// it's unavailable (fails fast; no fallback pool, matching
// services/azureblob/azurequeue/azuretable).
Port int `` //nolint:lll // config struct tags are intentionally verbose
/* 252-byte string literal not displayed */
}
Settings holds service-level configuration for the shared Azure Storage virtual-hosted listener. Mirrors services/azureblob's Settings pattern.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings returns the default Settings. Used when no ConfigProvider is available at init time (e.g. tests constructing a Provider directly).
type StorageHandler ¶
type StorageHandler interface {
Handler() echo.HandlerFunc
}
StorageHandler is the subset of *azureblob.Handler / *azurequeue.Handler / *azuretable.Handler this package needs: just the Echo handler each already exposes. Kept as an interface (rather than importing those three concrete packages) so this package has no compile-time dependency on their internals -- wiring the concrete *Handler values in happens once, in cli.go's cross-service wiring, exactly like every other already-initialized-handler dependency in this repo (e.g. wireSNSToSQS).