Documentation
¶
Index ¶
- Constants
- Variables
- func ParseAccountKeys(spec string) map[string]string
- type AppendOptions
- type AppendResult
- type BlobAttrs
- type BlobEvent
- type BlobEventSink
- type BlobInfo
- type BlobPage
- type BlockEntry
- type BlockList
- type BlockRef
- type ConfigProvider
- type ContainerInfo
- type ContainerOptions
- type ContainerPage
- type CopyRequest
- type CorsProps
- type CorsRule
- type ExternalBlob
- type FindBlobsOptions
- type FindBlobsPage
- type FoundBlob
- type Handler
- func (h *Handler) AuthorizeRead(account, container, blob, rawQuery string) error
- 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) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) SetAllowExternalCopy(allow bool)
- func (h *Handler) SetClock(clock func() time.Time)
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- type InMemoryBackend
- func (b *InMemoryBackend) AbortCopy(container, blob, copyID string, pre ...Precond) error
- func (b *InMemoryBackend) AppendBlock(container, blob string, data []byte, opts AppendOptions, pre ...Precond) (AppendResult, error)
- func (b *InMemoryBackend) CommitBlockList(container, blob string, refs []BlockRef, attrs BlobAttrs, pre ...Precond) (BlobInfo, error)
- func (b *InMemoryBackend) CopyBlob(srcContainer, srcBlob, srcSnapshot, dstContainer, dstBlob string, ...) (BlobInfo, error)
- func (b *InMemoryBackend) CopyBlobData(dstContainer, dstBlob string, src ExternalBlob, req CopyRequest, ...) (BlobInfo, error)
- func (b *InMemoryBackend) CreateContainer(name string) error
- func (b *InMemoryBackend) CreateContainerWith(name string, opts ContainerOptions) (ContainerInfo, error)
- func (b *InMemoryBackend) DeleteBlob(container, blob string) error
- func (b *InMemoryBackend) DeleteBlobAt(container, blob, snapshot, mode string, pre ...Precond) error
- func (b *InMemoryBackend) DeleteContainer(name string, pre ...Precond) error
- func (b *InMemoryBackend) FindBlobsByTags(container string, opts FindBlobsOptions) (FindBlobsPage, error)
- func (b *InMemoryBackend) GetBlob(container, blob string) (BlobInfo, []byte, error)
- func (b *InMemoryBackend) GetBlobAt(container, blob, snapshot string, pre ...Precond) (BlobInfo, []byte, error)
- func (b *InMemoryBackend) GetBlobTags(container, blob, snapshot string, pre ...Precond) (map[string]string, error)
- func (b *InMemoryBackend) GetBlockList(container, blob, snapshot, listType string, pre ...Precond) (BlockList, error)
- func (b *InMemoryBackend) GetContainer(name string, pre ...Precond) (ContainerInfo, error)
- func (b *InMemoryBackend) GetPageRanges(container, blob, snapshot string, from, to *int64, pre ...Precond) ([]PageRange, BlobInfo, error)
- func (b *InMemoryBackend) GetServiceProperties() ServiceProperties
- func (b *InMemoryBackend) HeadBlob(container, blob string) (BlobInfo, error)
- func (b *InMemoryBackend) HeadBlobAt(container, blob, snapshot string, pre ...Precond) (BlobInfo, error)
- func (b *InMemoryBackend) LeaseBlob(container, blob string, req LeaseRequest) (LeaseResult, error)
- func (b *InMemoryBackend) LeaseContainer(container string, req LeaseRequest) (LeaseResult, error)
- func (b *InMemoryBackend) ListBlobs(container string) ([]BlobInfo, error)
- func (b *InMemoryBackend) ListBlobsPage(container string, opts ListBlobsOptions) (BlobPage, error)
- func (b *InMemoryBackend) ListContainers() []ContainerInfo
- func (b *InMemoryBackend) ListContainersPage(opts ListContainersOptions) (ContainerPage, error)
- func (b *InMemoryBackend) PutBlob(container, blob string, data []byte, contentType string) (BlobInfo, error)
- func (b *InMemoryBackend) PutBlobWith(container, blob string, data []byte, attrs BlobAttrs, pre ...Precond) (BlobInfo, error)
- func (b *InMemoryBackend) PutBlock(container, blob, blockID string, data []byte, pre ...Precond) error
- func (b *InMemoryBackend) PutPage(container, blob string, start, end int64, data []byte, wipe bool, ...) (BlobInfo, error)
- func (b *InMemoryBackend) ReadTail(container, blob string, n int64) (BlobInfo, []byte, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) ResizePageBlob(container, blob string, length int64, pre ...Precond) (BlobInfo, error)
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetBlobMetadata(container, blob string, md map[string]string, pre ...Precond) (BlobInfo, error)
- func (b *InMemoryBackend) SetBlobProperties(container, blob string, attrs BlobAttrs, pre ...Precond) (BlobInfo, error)
- func (b *InMemoryBackend) SetBlobTags(container, blob, snapshot string, tags map[string]string, pre ...Precond) error
- func (b *InMemoryBackend) SetBlobTier(container, blob, tier string, pre ...Precond) (string, BlobInfo, error)
- func (b *InMemoryBackend) SetBlobTierWith(container, blob string, req TierRequest, pre ...Precond) (string, BlobInfo, error)
- func (b *InMemoryBackend) SetContainerACL(name, publicAccess string, ids []SignedIdentifier, pre ...Precond) (ContainerInfo, error)
- func (b *InMemoryBackend) SetContainerMetadata(name string, md map[string]string, pre ...Precond) (ContainerInfo, error)
- func (b *InMemoryBackend) SetServiceProperties(sp ServiceProperties) error
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) SnapshotBlob(container, blob string, md map[string]string, pre ...Precond) (BlobInfo, error)
- func (b *InMemoryBackend) UndeleteBlob(container, blob string) error
- type LeaseProps
- type LeaseRequest
- type LeaseResult
- type ListBlobsOptions
- type ListContainersOptions
- type ListEntry
- type LoggingProps
- type MetricsProps
- type PageRange
- type Precond
- type Provider
- type RetentionPolicy
- type ServiceProperties
- type Settings
- type SignedIdentifier
- type StaticWebsiteProps
- type StorageBackend
- type StorageError
- type TierRequest
Constants ¶
const ( BlobTypeBlock = "BlockBlob" BlobTypeAppend = "AppendBlob" BlobTypePage = "PageBlob" )
Blob types of the x-ms-blob-type header.
const ( PageSize = 512 MaxPageWrite = 4 << 20 MaxAppendBlockSize = 4 << 20 // MaxAppendBlocks is the committed-block limit of an append blob. MaxAppendBlocks = 50000 // MaxPageBlobLength is the emulator's size cap for a page blob (the service allows 8 TiB). MaxPageBlobLength = 256 << 20 )
Page and append blob limits (Put Page, Append Block, Put Blob references).
const ( CopyStatusSuccess = "success" CopyStatusPending = "pending" )
Values of x-ms-copy-status.
const ( // UncommittedBlockTTL is how long a staged block lives without a commit. UncommittedBlockTTL = 7 * 24 * time.Hour // MaxBlocksPerBlob is the Put Block List block-count limit. MaxBlocksPerBlob = 50000 // MaxBlockSize is the largest Put Block body (4000 MiB). MaxBlockSize = 4000 << 20 )
const ( BlockKindCommitted = "Committed" BlockKindUncommitted = "Uncommitted" BlockKindLatest = "Latest" BlockListCommitted = "committed" BlockListUncommitted = "uncommitted" BlockListAll = "all" )
Block kinds in a Put Block List request and values of blocklisttype.
const ( EventBlobCreated = "Microsoft.Storage.BlobCreated" EventBlobDeleted = "Microsoft.Storage.BlobDeleted" EventBlobTierChanged = "Microsoft.Storage.BlobTierChanged" EventAsyncOperation = "Microsoft.Storage.AsyncOperationInitiated" )
Event types and operation names of the Blob Storage Event Grid source.
const ( LeaseStateAvailable = "available" LeaseStateLeased = "leased" LeaseStateExpired = "expired" LeaseStateBreaking = "breaking" LeaseStateBroken = "broken" LeaseStatusLocked = "locked" LeaseStatusUnlocked = "unlocked" LeaseDurationInfinite = "infinite" LeaseDurationFixed = "fixed" )
Lease states and statuses as reported in x-ms-lease-state / x-ms-lease-status.
const ( LeaseActionAcquire = "acquire" LeaseActionRenew = "renew" LeaseActionChange = "change" LeaseActionRelease = "release" LeaseActionBreak = "break" )
Values of the x-ms-lease-action header.
const ( TierHot = "Hot" TierCool = "Cool" TierCold = "Cold" TierArchive = "Archive" AccessBlob = "blob" AccessContainer = "container" )
Access tiers and public-access levels accepted by the REST API.
const ( DeleteSnapshotsInclude = "include" DeleteSnapshotsOnly = "only" )
DeleteSnapshots values of the x-ms-delete-snapshots header.
const ( RehydratePriorityStandard = "Standard" RehydratePriorityHigh = "High" RehydrateStandardAfter = 15 * time.Hour RehydrateHighAfter = time.Hour )
Rehydration times of an Archive blob moved to an online tier, by x-ms-rehydrate-priority (the upper bounds the Blob rehydration documentation gives for Standard and High priority).
const ( DevStoreAccount = "devstoreaccount1" DevStoreKey = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" )
DevStoreAccount and DevStoreKey are the well-known development account and key every Azure Storage emulator and SDK documents; they are always accepted when signature verification is on.
const DefaultPort = 10000
DefaultPort is Azure Blob's fixed, protocol-conventional TCP port. This follows the same pattern as services/iot's MQTT broker (also a fixed, protocol-conventional default -- 1883 -- with a CLI/env override and no shared-pool fallback): pick one default and try to bind exactly that, rather than drawing from cli.go's shared --port-range-start/ --port-range-end PortAlloc pool (used for on-demand ephemeral resources like Lambda function URLs and ElastiCache, not fixed service ports) or inventing an alternative numbering scheme. The default value itself (10000) is Azurite's own Blob service port, so unmodified UseDevelopmentStorage=true-style SDK configuration works out of the box; see AZURE.md section 4 for the full rationale, including why this deliberately does NOT fall back into the shared PortAlloc pool if 10000 is taken (StartWorker fails fast instead -- see handler.go).
const LeaseInfinite = -1
LeaseInfinite is the x-ms-lease-duration value of an infinite lease.
const MaxCopySourceBytes = 256 << 20
MaxCopySourceBytes bounds the body fetched from a copy source URL.
Variables ¶
var ( ErrContainerNotFound = errors.New("azureblob: container not found") ErrContainerAlreadyExists = errors.New("azureblob: container already exists") ErrBlobNotFound = errors.New("azureblob: blob not found") ErrSnapshotsPresent = errors.New("azureblob: blob has snapshots") ErrInvalidMarker = errors.New("azureblob: invalid list marker") // ErrSnapshotContainerNull and ErrSnapshotBlobNull are returned by // Restore when a snapshot's "containers" map (or a container's "Blobs" // map) holds a JSON null entry, which decodes to a nil pointer that // would panic on first dereference if stored as-is. See persistence.go. ErrSnapshotContainerNull = errors.New("azureblob: restore snapshot: container is null") ErrSnapshotBlobNull = errors.New("azureblob: restore snapshot: blob is null") )
Sentinel errors for Azure Blob Storage operations.
var ErrBlobReadDenied = errors.New("azureblob: blob read denied")
ErrBlobReadDenied is returned by AuthorizeRead when the blob service would refuse the read.
var ErrNilAppContext = errors.New("azureblob: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
Functions ¶
func ParseAccountKeys ¶
ParseAccountKeys parses "account=base64key,account2=key2" into a map.
Types ¶
type AppendOptions ¶
AppendOptions are the conditional headers of Append Block.
type AppendResult ¶
AppendResult reports where an Append Block landed.
type BlobAttrs ¶
type BlobAttrs struct {
Metadata map[string]string
Tags map[string]string
ContentType string
ContentEncoding string
ContentLanguage string
ContentDisposition string
CacheControl string
ContentMD5 string
AccessTier string
BlobType string
PageLength int64
SequenceNumber int64
}
BlobAttrs are the client-settable properties of a blob.
type BlobEvent ¶
type BlobEvent struct {
Time time.Time
Account string
Container string
Blob string
EventType string
API string
ContentType string
ETag string
AccessTier string
RequestID string
ClientRequestID string
ContentLength int64
}
BlobEvent describes a committed blob create/replace or a blob delete.
type BlobEventSink ¶
type BlobEventSink interface {
OnBlobEvent(ev BlobEvent)
}
BlobEventSink receives blob events after the operation succeeded.
type BlobInfo ¶
type BlobInfo struct {
LastModified time.Time
AccessTierChanged time.Time
Metadata map[string]string
Tags map[string]string
Name string
ContentType string
ContentEncoding string
ContentLanguage string
ContentDisposition string
CacheControl string
ContentMD5 string
ETag string
AccessTier string
Snapshot string
CopyCompletion time.Time
DeletedTime time.Time
Lease LeaseProps
BlobType string
ArchiveStatus string
CopyID string
CopyStatus string
CopySource string
CopyProgress string
ContentLength int64
SequenceNumber int64
CommittedBlocks int
RetentionDays int
AccessTierInferred bool
Deleted bool
}
BlobInfo is a read-only snapshot of a blob (or of one of its snapshots), returned by the StorageBackend blob accessors.
type BlockEntry ¶
BlockEntry is one block of a Get Block List response.
type BlockList ¶
type BlockList struct {
Committed []BlockEntry
Uncommitted []BlockEntry
Blob BlobInfo
HasBlob bool
}
BlockList is the Get Block List result. HasBlob is false when only uncommitted blocks exist.
type ConfigProvider ¶
type ConfigProvider interface {
GetAzureBlobSettings() Settings
}
ConfigProvider is a private interface to extract AzureBlob configuration from the abstract AppContext Config, mirroring services/s3.ConfigProvider.
type ContainerInfo ¶
type ContainerInfo struct {
CreatedAt time.Time
LastModified time.Time
Metadata map[string]string
Lease LeaseProps
Name string
ETag string
PublicAccess string
ACL []SignedIdentifier
}
ContainerInfo is a read-only snapshot of a container, returned by the StorageBackend container accessors. It carries no reference to backend storage.
type ContainerOptions ¶
ContainerOptions are the create-time settings of a container.
type ContainerPage ¶
type ContainerPage struct {
NextMarker string
Containers []ContainerInfo
}
ContainerPage is one page of a List Containers response.
type CopyRequest ¶
CopyRequest carries the destination settings of a Copy Blob. A nil Metadata inherits the source's; tags are never inherited. SourceURL is recorded as x-ms-copy-source with any SAS removed.
type CorsProps ¶
type CorsProps struct {
Rules []CorsRule `xml:"CorsRule"`
}
CorsProps is the Cors element.
type CorsRule ¶
type CorsRule struct {
AllowedOrigins string `xml:"AllowedOrigins"`
AllowedMethods string `xml:"AllowedMethods"`
ExposedHeaders string `xml:"ExposedHeaders"`
AllowedHeaders string `xml:"AllowedHeaders"`
MaxAgeInSeconds int `xml:"MaxAgeInSeconds"`
}
CorsRule is one CORS rule.
type ExternalBlob ¶
ExternalBlob is the content and properties of a blob fetched from a source URL.
type FindBlobsOptions ¶
FindBlobsOptions are the Find Blobs by Tags parameters. Container is empty for account scope; the filter's own @container clause narrows it further.
type FindBlobsPage ¶
FindBlobsPage is one page of a Find Blobs by Tags response.
type Handler ¶
type Handler struct {
Backend StorageBackend
Events BlobEventSink
AccountKeys map[string]string
Endpoint string
Port int
EnforcePublicAccess bool
VerifySignatures bool
// contains filtered or unexported fields
}
Handler is the Echo HTTP handler for Azure Blob Storage operations.
func NewHandler ¶
func NewHandler(backend StorageBackend) *Handler
NewHandler creates a new Azure Blob Handler. Port defaults to DefaultPort; callers (typically provider.go) override it from Settings.
func (*Handler) AuthorizeRead ¶
AuthorizeRead applies the blob service's own read authorization (SAS signature, public access level) to an in-process read of a blob addressed by a URL whose query is rawQuery.
func (*Handler) ExtractOperation ¶
ExtractOperation extracts the Azure Blob operation name from the request, for metrics labeling.
func (*Handler) ExtractResource ¶
ExtractResource extracts the container/blob resource identifier from the request path, for metrics labeling.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations returns the list of supported Azure Blob operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler function for Azure Blob operations.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority for the AzureBlob handler. Irrelevant in practice since RouteMatcher never matches; 0 (lowest) is the safe default.
func (*Handler) Reset ¶
func (h *Handler) Reset()
Reset clears all in-memory state from the backend. It is used by the POST /_gopherstack/reset endpoint for CI pipelines and rapid local development.
func (*Handler) RouteMatcher ¶
RouteMatcher exists only to satisfy service.Registerable's interface contract: AzureBlob deliberately never matches on the shared AWS single-port Router. It runs on its own dedicated listener started by StartWorker (see provider.go for the full rationale). AzureBlob's Provider IS registered in cli.go's getMostRecentServiceProviders like every other service -- startBackgroundWorkers calls StartWorker via the service.BackgroundWorker interface regardless of routing, which is how the dedicated listener comes up. Only RouteMatcher itself is inert, kept so *Handler satisfies service.Registerable.
func (*Handler) SetAllowExternalCopy ¶
SetAllowExternalCopy lets copy sources resolve to non-loopback addresses; by default only loopback is reachable.
func (*Handler) SetClock ¶
SetClock replaces the clock used for SAS validity windows and request-date checks.
func (*Handler) Shutdown ¶
Shutdown stops the dedicated Blob listener. A graceful Shutdown error (e.g. its context expiring before active connections finish) is logged and followed by Close, which forcibly closes the listener and any remaining idle/active connections; any Close error is logged too rather than leaving the listener to leak silently.
func (*Handler) Snapshot ¶
Snapshot implements persistence.Persistable by delegating to the backend.
func (*Handler) StartWorker ¶
StartWorker binds the dedicated Blob listener and starts serving on it. See provider.go's Provider doc comment for why AzureBlob needs its own listener instead of registering into the shared AWS Router.
Binding is synchronous: net.Listen returns before StartWorker does, so a bind failure is returned to the caller directly instead of only being logged from the background goroutine after startup has already reported success. This mirrors services/iot's MQTT broker (services/iot/broker.go), gopherstack's existing precedent for a service with a fixed, protocol-conventional default port: bind exactly the configured port (h.Port, from Settings -- see settings.go/provider.go) and fail fast if that's unavailable, rather than silently falling back into the shared --port-range-start/--port-range-end PortAlloc pool used for on-demand ephemeral resources elsewhere (Lambda function URLs, ElastiCache). A fallback there would be just as surprising as picking a different default port number outright: either way, an SDK relying on the well-known default (UseDevelopmentStorage=true-style config) would silently end up talking to the wrong port. Failing fast surfaces the conflict instead.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend implements StorageBackend using in-memory maps guarded by a single RWMutex. Shaped after services/sqs's InMemoryBackend, but simpler: Azure Blob's MVP surface (see AZURE.md/PARITY.md) has no janitor, no metrics emitter, and no cross-resource relationships to track, so a single coarse lock over one map of containers is sufficient.
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates a new empty InMemoryBackend.
func NewInMemoryBackendWithClock ¶
func NewInMemoryBackendWithClock(clock func() time.Time) *InMemoryBackend
NewInMemoryBackendWithClock is NewInMemoryBackend with an injectable clock driving timestamps, lease expiry and uncommitted-block expiry.
func (*InMemoryBackend) AbortCopy ¶
func (b *InMemoryBackend) AbortCopy(container, blob, copyID string, pre ...Precond) error
AbortCopy aborts a pending copy. Copies complete synchronously, so a destination never has one pending.
func (*InMemoryBackend) AppendBlock ¶
func (b *InMemoryBackend) AppendBlock( container, blob string, data []byte, opts AppendOptions, pre ...Precond, ) (AppendResult, error)
AppendBlock appends data to an append blob.
func (*InMemoryBackend) CommitBlockList ¶
func (b *InMemoryBackend) CommitBlockList( container, blob string, refs []BlockRef, attrs BlobAttrs, pre ...Precond, ) (BlobInfo, error)
CommitBlockList assembles blob from staged and committed blocks, then discards every uncommitted block of the blob.
func (*InMemoryBackend) CopyBlob ¶
func (b *InMemoryBackend) CopyBlob( srcContainer, srcBlob, srcSnapshot, dstContainer, dstBlob string, req CopyRequest, pre ...Precond, ) (BlobInfo, error)
CopyBlob copies a blob (or snapshot) within the account and records the x-ms-copy-* properties on the destination.
func (*InMemoryBackend) CopyBlobData ¶
func (b *InMemoryBackend) CopyBlobData( dstContainer, dstBlob string, src ExternalBlob, req CopyRequest, pre ...Precond, ) (BlobInfo, error)
CopyBlobData stores content fetched from a source URL as a block blob and records the copy properties.
func (*InMemoryBackend) CreateContainer ¶
func (b *InMemoryBackend) CreateContainer(name string) error
CreateContainer creates a new, empty container with default settings.
func (*InMemoryBackend) CreateContainerWith ¶
func (b *InMemoryBackend) CreateContainerWith(name string, opts ContainerOptions) (ContainerInfo, error)
CreateContainerWith creates a container with metadata and a public-access level. Returns ErrContainerAlreadyExists if the name is taken.
func (*InMemoryBackend) DeleteBlob ¶
func (b *InMemoryBackend) DeleteBlob(container, blob string) error
DeleteBlob removes a blob that has no snapshots.
func (*InMemoryBackend) DeleteBlobAt ¶
func (b *InMemoryBackend) DeleteBlobAt(container, blob, snapshot, mode string, pre ...Precond) error
DeleteBlobAt deletes a snapshot (snapshot != ""), or the base blob subject to the x-ms-delete-snapshots mode: with snapshots present, "" fails with ErrSnapshotsPresent, "include" removes all, "only" removes just snapshots.
func (*InMemoryBackend) DeleteContainer ¶
func (b *InMemoryBackend) DeleteContainer(name string, pre ...Precond) error
DeleteContainer removes a container and all of its blobs. Returns ErrContainerNotFound if the container does not exist. An active container lease requires the matching lease id.
func (*InMemoryBackend) FindBlobsByTags ¶
func (b *InMemoryBackend) FindBlobsByTags(container string, opts FindBlobsOptions) (FindBlobsPage, error)
FindBlobsByTags lists base blobs whose tags satisfy the filter, ordered by container then blob name, with marker paging.
func (*InMemoryBackend) GetBlob ¶
func (b *InMemoryBackend) GetBlob(container, blob string) (BlobInfo, []byte, error)
GetBlob returns a blob's metadata and full body; the slice is immutable backend storage and must not be modified.
func (*InMemoryBackend) GetBlobAt ¶
func (b *InMemoryBackend) GetBlobAt(container, blob, snapshot string, pre ...Precond) (BlobInfo, []byte, error)
GetBlobAt is GetBlob for the base blob (snapshot == "") or one snapshot. Conditional headers and an optional lease id are evaluated.
func (*InMemoryBackend) GetBlobTags ¶
func (b *InMemoryBackend) GetBlobTags( container, blob, snapshot string, pre ...Precond, ) (map[string]string, error)
GetBlobTags returns a copy of a blob's or snapshot's tags.
func (*InMemoryBackend) GetBlockList ¶
func (b *InMemoryBackend) GetBlockList( container, blob, snapshot, listType string, pre ...Precond, ) (BlockList, error)
GetBlockList lists committed and/or uncommitted blocks. listType is "committed", "uncommitted" or "all".
func (*InMemoryBackend) GetContainer ¶
func (b *InMemoryBackend) GetContainer(name string, pre ...Precond) (ContainerInfo, error)
GetContainer returns a container's properties, metadata and ACL. A lease id, when given, must match an active lease.
func (*InMemoryBackend) GetPageRanges ¶
func (b *InMemoryBackend) GetPageRanges( container, blob, snapshot string, from, to *int64, pre ...Precond, ) ([]PageRange, BlobInfo, error)
GetPageRanges lists the valid page ranges of a page blob or snapshot, optionally within [from,to].
func (*InMemoryBackend) GetServiceProperties ¶
func (b *InMemoryBackend) GetServiceProperties() ServiceProperties
GetServiceProperties returns the account's Blob service properties.
func (*InMemoryBackend) HeadBlob ¶
func (b *InMemoryBackend) HeadBlob(container, blob string) (BlobInfo, error)
HeadBlob returns a blob's metadata without its body.
func (*InMemoryBackend) HeadBlobAt ¶
func (b *InMemoryBackend) HeadBlobAt(container, blob, snapshot string, pre ...Precond) (BlobInfo, error)
HeadBlobAt is HeadBlob for the base blob (snapshot == "") or one snapshot.
func (*InMemoryBackend) LeaseBlob ¶
func (b *InMemoryBackend) LeaseBlob(container, blob string, req LeaseRequest) (LeaseResult, error)
LeaseBlob runs a lease action on a blob. Conditional headers apply.
func (*InMemoryBackend) LeaseContainer ¶
func (b *InMemoryBackend) LeaseContainer(container string, req LeaseRequest) (LeaseResult, error)
LeaseContainer runs a lease action on a container.
func (*InMemoryBackend) ListBlobs ¶
func (b *InMemoryBackend) ListBlobs(container string) ([]BlobInfo, error)
ListBlobs returns every base blob in container, sorted by name. Returns ErrContainerNotFound if the container does not exist.
func (*InMemoryBackend) ListBlobsPage ¶
func (b *InMemoryBackend) ListBlobsPage(container string, opts ListBlobsOptions) (BlobPage, error)
ListBlobsPage lists blobs with prefix/delimiter collapsing and marker paging. Returns ErrContainerNotFound or ErrInvalidMarker.
func (*InMemoryBackend) ListContainers ¶
func (b *InMemoryBackend) ListContainers() []ContainerInfo
ListContainers returns a snapshot of all containers, sorted by name (the order Azure's List Containers returns them in).
func (*InMemoryBackend) ListContainersPage ¶
func (b *InMemoryBackend) ListContainersPage(opts ListContainersOptions) (ContainerPage, error)
ListContainersPage lists containers with prefix filtering and marker paging. Returns ErrInvalidMarker for a marker it did not issue.
func (*InMemoryBackend) PutBlob ¶
func (b *InMemoryBackend) PutBlob(container, blob string, data []byte, contentType string) (BlobInfo, error)
PutBlob stores data as a block blob with only a content type set.
func (*InMemoryBackend) PutBlobWith ¶
func (b *InMemoryBackend) PutBlobWith( container, blob string, data []byte, attrs BlobAttrs, pre ...Precond, ) (BlobInfo, error)
PutBlobWith stores data as a block blob named blob within container, replacing any existing blob but keeping its snapshots and lease, as Azure does. Returns ErrContainerNotFound if the container does not exist.
func (*InMemoryBackend) PutBlock ¶
func (b *InMemoryBackend) PutBlock(container, blob, blockID string, data []byte, pre ...Precond) error
PutBlock stages an uncommitted block for blob. All block ids of a blob must decode to the same length. The blob need not exist yet.
func (*InMemoryBackend) PutPage ¶
func (b *InMemoryBackend) PutPage( container, blob string, start, end int64, data []byte, wipe bool, pre ...Precond, ) (BlobInfo, error)
PutPage writes or clears the page range [start,end] of a page blob.
func (*InMemoryBackend) ReadTail ¶
ReadTail returns the blob's info and its last n bytes (fewer if the blob is shorter) without materialising the rest of a page blob.
func (*InMemoryBackend) Reset ¶
func (b *InMemoryBackend) Reset()
Reset clears all in-memory state. It is used by the POST /_gopherstack/reset endpoint for CI pipelines and rapid local development.
func (*InMemoryBackend) ResizePageBlob ¶
func (b *InMemoryBackend) ResizePageBlob(container, blob string, length int64, pre ...Precond) (BlobInfo, error)
ResizePageBlob sets the length of a page blob; shrinking discards pages beyond it.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a JSON snapshot. It implements persistence.Persistable.
func (*InMemoryBackend) SetBlobMetadata ¶
func (b *InMemoryBackend) SetBlobMetadata( container, blob string, md map[string]string, pre ...Precond, ) (BlobInfo, error)
SetBlobMetadata replaces a blob's metadata.
func (*InMemoryBackend) SetBlobProperties ¶
func (b *InMemoryBackend) SetBlobProperties( container, blob string, attrs BlobAttrs, pre ...Precond, ) (BlobInfo, error)
SetBlobProperties replaces the content properties of a blob. Properties absent from attrs are cleared, as in Set Blob Properties.
func (*InMemoryBackend) SetBlobTags ¶
func (b *InMemoryBackend) SetBlobTags( container, blob, snapshot string, tags map[string]string, pre ...Precond, ) error
SetBlobTags replaces all tags of a blob or snapshot. ETag and Last-Modified are unchanged.
func (*InMemoryBackend) SetBlobTier ¶
func (b *InMemoryBackend) SetBlobTier(container, blob, tier string, pre ...Precond) (string, BlobInfo, error)
SetBlobTier sets the access tier at standard rehydration priority and returns the tier it replaced.
func (*InMemoryBackend) SetBlobTierWith ¶
func (b *InMemoryBackend) SetBlobTierWith( container, blob string, req TierRequest, pre ...Precond, ) (string, BlobInfo, error)
SetBlobTierWith sets the access tier. Leaving Archive starts an asynchronous rehydration that completes once the priority's duration has elapsed; until then the blob stays Archive with x-ms-archive-status set.
func (*InMemoryBackend) SetContainerACL ¶
func (b *InMemoryBackend) SetContainerACL( name, publicAccess string, ids []SignedIdentifier, pre ...Precond, ) (ContainerInfo, error)
SetContainerACL replaces a container's public-access level and stored access policies.
func (*InMemoryBackend) SetContainerMetadata ¶
func (b *InMemoryBackend) SetContainerMetadata( name string, md map[string]string, pre ...Precond, ) (ContainerInfo, error)
SetContainerMetadata replaces a container's metadata.
func (*InMemoryBackend) SetServiceProperties ¶
func (b *InMemoryBackend) SetServiceProperties(sp ServiceProperties) error
SetServiceProperties merges the supplied elements into the stored properties.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state to JSON. It implements persistence.Persistable.
func (*InMemoryBackend) SnapshotBlob ¶
func (b *InMemoryBackend) SnapshotBlob(container, blob string, md map[string]string, pre ...Precond) (BlobInfo, error)
SnapshotBlob freezes a copy of the blob. A nil md inherits the blob's metadata; a non-nil md (even empty) replaces it.
func (*InMemoryBackend) UndeleteBlob ¶
func (b *InMemoryBackend) UndeleteBlob(container, blob string) error
UndeleteBlob restores a soft-deleted blob with its snapshots; a blob that is not deleted is left as it is.
type LeaseProps ¶
LeaseProps are the lease fields reported in blob and container properties.
type LeaseRequest ¶
type LeaseRequest struct {
Action string
ID string
ProposedID string
Cond Precond
// Duration is seconds, or LeaseInfinite; used by acquire.
Duration int
// BreakPeriod is seconds; used by break when HasBreakPeriod.
BreakPeriod int
HasBreakPeriod bool
}
LeaseRequest is one Lease Blob / Lease Container call.
type LeaseResult ¶
type LeaseResult struct {
LastModified time.Time
ID string
ETag string
// BreakRemaining is x-ms-lease-time, whole seconds left in the break period.
BreakRemaining int
}
LeaseResult is the outcome of a lease call.
type ListBlobsOptions ¶
type ListBlobsOptions struct {
Prefix string
Delimiter string
Marker string
MaxResults int
IncludeSnapshots bool
IncludeTags bool
IncludeDeleted bool
}
ListBlobsOptions are the List Blobs query parameters.
type ListContainersOptions ¶
ListContainersOptions are the List Containers query parameters.
type ListEntry ¶
type ListEntry struct {
Prefix string
Blob BlobInfo
// IsPrefix selects Prefix over Blob.
IsPrefix bool
}
ListEntry is one item of a List Blobs page: a blob or a BlobPrefix.
type LoggingProps ¶
type LoggingProps struct {
RetentionPolicy *RetentionPolicy `xml:"RetentionPolicy,omitempty"`
Version string `xml:"Version"`
Delete bool `xml:"Delete"`
Read bool `xml:"Read"`
Write bool `xml:"Write"`
}
LoggingProps is the Logging element.
type MetricsProps ¶
type MetricsProps struct {
IncludeAPIs *bool `xml:"IncludeAPIs,omitempty"`
RetentionPolicy *RetentionPolicy `xml:"RetentionPolicy,omitempty"`
Version string `xml:"Version"`
Enabled bool `xml:"Enabled"`
}
MetricsProps is the HourMetrics / MinuteMetrics element.
type Precond ¶
type Precond struct {
Source *Precond
IfModifiedSince time.Time
IfUnmodifiedSince time.Time
IfMatch string
IfNoneMatch string
IfTags string
LeaseID string
}
Precond carries the conditional headers and lease id of one request. Zero time and empty string mean "header absent". Source holds the x-ms-source-if-* conditions of copy-style operations.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for the Azure Blob Storage service.
Unlike every other provider in this repo, AzureBlob does not register a RouteMatcher into the shared AWS single-port Router: Azure Blob's path shape (/<account>/<container>/<blob>) has no service-identifying header the way AWS's X-Amz-Target does, so multiplexing it onto the shared port risks exactly the collision the router avoids by construction for AWS services (see AZURE.md section 4). Instead the returned Handler implements service.BackgroundWorker and stands up its own dedicated *echo.Echo/ *http.Server, listening on a fixed, protocol-conventional port -- the same pattern services/iot's MQTT broker already uses in this repo for a well-known port (1883) that isn't part of the shared AWS request/response cycle. It is registered in cli.go's getMostRecentServiceProviders like every other provider; only its RouteMatcher (which always returns false) is inert.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the AzureBlob service backend and handler. The configured port (Settings.Port, default DefaultPort) is only recorded here; the actual TCP bind happens synchronously in Handler.StartWorker, so a port-in-use failure is returned to the caller directly instead of being discovered later from a background goroutine.
type RetentionPolicy ¶
type RetentionPolicy struct {
Days *int `xml:"Days,omitempty"`
AllowPermanentDelete *bool `xml:"AllowPermanentDelete,omitempty"`
Enabled bool `xml:"Enabled"`
}
RetentionPolicy is a retention element of the Blob service properties.
type ServiceProperties ¶
type ServiceProperties struct {
Logging *LoggingProps `xml:"Logging,omitempty"`
HourMetrics *MetricsProps `xml:"HourMetrics,omitempty"`
MinuteMetrics *MetricsProps `xml:"MinuteMetrics,omitempty"`
Cors *CorsProps `xml:"Cors,omitempty"`
DeleteRetentionPolicy *RetentionPolicy `xml:"DeleteRetentionPolicy,omitempty"`
StaticWebsite *StaticWebsiteProps `xml:"StaticWebsite,omitempty"`
XMLName xml.Name `xml:"StorageServiceProperties" json:"-"`
DefaultServiceVersion string `xml:"DefaultServiceVersion,omitempty"`
}
ServiceProperties is the StorageServiceProperties document of Get/Set Blob Service Properties.
type Settings ¶
type Settings struct {
AccountKeys string `` //nolint:lll // config struct tags are intentionally verbose
/* 223-byte string literal not displayed */
Port int `` //nolint:lll // config struct tags are intentionally verbose
/* 301-byte string literal not displayed */
EnforcePublicAccess bool `` //nolint:lll // config struct tags are intentionally verbose
/* 247-byte string literal not displayed */
VerifySignatures bool `` //nolint:lll // config struct tags are intentionally verbose
/* 285-byte string literal not displayed */
AllowExternalCopy bool `` //nolint:lll // config struct tags are intentionally verbose
/* 221-byte string literal not displayed */
}
Settings holds service-level configuration for the Azure Blob backend. Fields are picked up by the Kong CLI parser when this struct is embedded in the root CLI command (see cli.go's CLI.AzureBlob field), mirroring services/s3'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 SignedIdentifier ¶
SignedIdentifier is one stored access policy of a container ACL.
type StaticWebsiteProps ¶
type StaticWebsiteProps struct {
IndexDocument string `xml:"IndexDocument,omitempty"`
ErrorDocument404Path string `xml:"ErrorDocument404Path,omitempty"`
DefaultIndexDocumentPth string `xml:"DefaultIndexDocumentPath,omitempty"`
Enabled bool `xml:"Enabled"`
}
StaticWebsiteProps is the StaticWebsite element.
type StorageBackend ¶
type StorageBackend interface {
CreateContainerWith(name string, opts ContainerOptions) (ContainerInfo, error)
DeleteContainer(name string, pre ...Precond) error
ListContainers() []ContainerInfo
ListContainersPage(opts ListContainersOptions) (ContainerPage, error)
GetContainer(name string, pre ...Precond) (ContainerInfo, error)
SetContainerMetadata(name string, md map[string]string, pre ...Precond) (ContainerInfo, error)
SetContainerACL(name, publicAccess string, ids []SignedIdentifier, pre ...Precond) (ContainerInfo, error)
LeaseContainer(container string, req LeaseRequest) (LeaseResult, error)
PutBlobWith(container, blob string, data []byte, attrs BlobAttrs, pre ...Precond) (BlobInfo, error)
GetBlobAt(container, blob, snapshot string, pre ...Precond) (BlobInfo, []byte, error)
HeadBlobAt(container, blob, snapshot string, pre ...Precond) (BlobInfo, error)
DeleteBlobAt(container, blob, snapshot, mode string, pre ...Precond) error
ListBlobsPage(container string, opts ListBlobsOptions) (BlobPage, error)
SetBlobProperties(container, blob string, attrs BlobAttrs, pre ...Precond) (BlobInfo, error)
SetBlobMetadata(container, blob string, md map[string]string, pre ...Precond) (BlobInfo, error)
SetBlobTier(container, blob, tier string, pre ...Precond) (string, BlobInfo, error)
SnapshotBlob(container, blob string, md map[string]string, pre ...Precond) (BlobInfo, error)
CopyBlob(
srcContainer, srcBlob, srcSnapshot, dstContainer, dstBlob string, req CopyRequest, pre ...Precond,
) (BlobInfo, error)
CopyBlobData(dstContainer, dstBlob string, src ExternalBlob, req CopyRequest, pre ...Precond) (BlobInfo, error)
AbortCopy(container, blob, copyID string, pre ...Precond) error
SetBlobTierWith(container, blob string, req TierRequest, pre ...Precond) (string, BlobInfo, error)
AppendBlock(container, blob string, data []byte, opts AppendOptions, pre ...Precond) (AppendResult, error)
PutPage(container, blob string, start, end int64, data []byte, wipe bool, pre ...Precond) (BlobInfo, error)
GetPageRanges(
container, blob, snapshot string, from, to *int64, pre ...Precond,
) ([]PageRange, BlobInfo, error)
UndeleteBlob(container, blob string) error
ReadTail(container, blob string, n int64) (BlobInfo, []byte, error)
ResizePageBlob(container, blob string, length int64, pre ...Precond) (BlobInfo, error)
GetServiceProperties() ServiceProperties
SetServiceProperties(sp ServiceProperties) error
LeaseBlob(container, blob string, req LeaseRequest) (LeaseResult, error)
SetBlobTags(container, blob, snapshot string, tags map[string]string, pre ...Precond) error
GetBlobTags(container, blob, snapshot string, pre ...Precond) (map[string]string, error)
FindBlobsByTags(container string, opts FindBlobsOptions) (FindBlobsPage, error)
PutBlock(container, blob, blockID string, data []byte, pre ...Precond) error
CommitBlockList(container, blob string, refs []BlockRef, attrs BlobAttrs, pre ...Precond) (BlobInfo, error)
GetBlockList(container, blob, snapshot, listType string, pre ...Precond) (BlockList, error)
// Reset clears all in-memory state. Used by the
// POST /_gopherstack/reset endpoint for CI pipelines and rapid local development.
Reset()
}
StorageBackend defines the interface for an Azure Blob Storage backend. Shaped after services/sqs's StorageBackend: a narrow, testable seam between the wire handler and storage, so handler tests can substitute a fake.
type StorageError ¶
StorageError is a backend failure that maps one-to-one onto an Azure Storage REST error response. Header is written on 304 responses.
func (*StorageError) Error ¶
func (e *StorageError) Error() string
type TierRequest ¶
TierRequest is a Set Blob Tier request.
Source Files
¶
- blob_kinds.go
- blocks.go
- errors.go
- events.go
- handler.go
- handler_blocks.go
- handler_cond.go
- handler_copy.go
- handler_ext.go
- handler_kinds.go
- handler_lease.go
- handler_tags.go
- interfaces.go
- lease.go
- list_encode.go
- models.go
- persistence.go
- precond.go
- provider.go
- service_props.go
- settings.go
- store.go
- store_ext.go
- store_tags.go
- tagexpr.go
- tags.go
- verify.go