shared

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderAuthorization     = "Authorization"
	HeaderXmsDate           = "x-ms-date"
	HeaderContentLength     = "Content-Length"
	HeaderContentEncoding   = "Content-Encoding"
	HeaderContentLanguage   = "Content-Language"
	HeaderContentType       = "Content-Type"
	HeaderContentMD5        = "Content-MD5"
	HeaderIfModifiedSince   = "If-Modified-Since"
	HeaderIfMatch           = "If-Match"
	HeaderIfNoneMatch       = "If-None-Match"
	HeaderIfUnmodifiedSince = "If-Unmodified-Since"
	HeaderRange             = "Range"
	HeaderXmsVersion        = "x-ms-version"
	HeaderXmsRequestID      = "x-ms-request-id"
)
View Source
const (
	DefaultConcurrency = 5
)
View Source
const (
	TokenScope = "https://storage.azure.com/.default"
)

Variables

View Source
var CRC64Table = crc64.MakeTable(crc64Polynomial)

Functions

func CopyOptions

func CopyOptions[T any](opts *T) *T

CopyOptions returns a zero-value T if opts is nil. If opts is not nil, a copy is made and its address returned.

func DoBatchTransfer

func DoBatchTransfer(ctx context.Context, o *BatchTransferOptions) error

DoBatchTransfer helps to execute operations in a batch manner. Can be used by users to customize batch works (for other scenarios that the SDK does not provide)

func GenerateLeaseID

func GenerateLeaseID(leaseID *string) (*string, error)

func GetClientOptions

func GetClientOptions[T any](o *T) *T

func IsIPEndpointStyle

func IsIPEndpointStyle(host string) bool

IsIPEndpointStyle checkes if URL's host is IP, in this case the storage account endpoint will be composed as: http(s)://IP(:port)/storageaccount/container/... As url's Host property, host could be both host or host:port

func NewBytesWriter

func NewBytesWriter(b []byte) bytesWriter

func NewStorageChallengePolicy added in v1.1.0

func NewStorageChallengePolicy(cred azcore.TokenCredential, audience string, allowHTTP bool) policy.Policy

func NopCloser

func NopCloser(rs io.ReadSeeker) io.ReadSeekCloser

NopCloser returns a ReadSeekCloser with a no-op close method wrapping the provided io.ReadSeeker.

func RangeToString

func RangeToString(offset, count int64) string

func ReadAtLeast added in v1.2.1

func ReadAtLeast(r io.Reader, buf []byte, min int) (n int, err error)

ReadAtLeast reads from r into buf until it has read at least min bytes. It returns the number of bytes copied and an error. The EOF error is returned if no bytes were read or EOF happened after reading fewer than min bytes. If min is greater than the length of buf, ReadAtLeast returns ErrShortBuffer. On return, n >= min if and only if err == nil. If r returns an error having read at least min bytes, the error is dropped. This method is same as io.ReadAtLeast except that it does not return io.ErrUnexpectedEOF when fewer than min bytes are read.

func SerializeBlobTags

func SerializeBlobTags(tagsMap map[string]string) *generated.BlobTags

SerializeBlobTags converts tags to generated.BlobTags

func SerializeBlobTagsToStrPtr

func SerializeBlobTagsToStrPtr(tagsMap map[string]string) *string

func ValidateSeekableStreamAt0AndGetCount

func ValidateSeekableStreamAt0AndGetCount(body io.ReadSeeker) (int64, error)

Types

type BatchTransferOptions

type BatchTransferOptions struct {
	TransferSize  int64
	ChunkSize     int64
	NumChunks     uint64
	Concurrency   uint16
	Operation     func(ctx context.Context, offset int64, chunkSize int64) error
	OperationName string
}

BatchTransferOptions identifies options used by doBatchTransfer.

type BufferManager added in v1.2.0

type BufferManager[T ~[]byte] interface {
	// Acquire returns the channel that contains the pool of buffers.
	Acquire() <-chan T

	// Release releases the buffer back to the pool for reuse/cleanup.
	Release(T)

	// Grow grows the number of buffers, up to the predefined max.
	// It returns the total number of buffers or an error.
	// No error is returned if the number of buffers has reached max.
	// This is called only from the reading goroutine.
	Grow() (int, error)

	// Free cleans up all buffers.
	Free()
}

func NewMMBPool added in v1.2.0

func NewMMBPool(maxBuffers int, bufferSize int64) BufferManager[Mmb]

type Mmb added in v1.2.0

type Mmb []byte

mmb is a memory mapped buffer

func NewMMB added in v1.2.0

func NewMMB(size int64) (Mmb, error)

newMMB creates a new memory mapped buffer with the specified size

func (*Mmb) Delete added in v1.2.0

func (m *Mmb) Delete()

delete cleans up the memory mapped buffer

type ParsedConnectionString

type ParsedConnectionString struct {
	ServiceURL  string
	AccountName string
	AccountKey  string
}

func ParseConnectionString

func ParseConnectionString(connectionString string) (ParsedConnectionString, error)

type SectionWriter

type SectionWriter struct {
	Count    int64
	Offset   int64
	Position int64
	WriterAt io.WriterAt
}

func NewSectionWriter

func NewSectionWriter(c io.WriterAt, off int64, count int64) *SectionWriter

func (*SectionWriter) Write

func (c *SectionWriter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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