dotc1z

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidFile        = fmt.Errorf("c1z: invalid file")
	ErrMaxSizeExceeded    = errors.New("c1z: max decoded size exceeded, increase DecoderMaxDecodedSize")
	ErrWindowSizeExceeded = errors.New("c1z: window size exceeded, increase DecoderMaxMemory")
)
View Source
var C1ZFileHeader = []byte("C1ZF\x00")

Functions

func NewDecoder

func NewDecoder(f io.Reader, opts ...DecoderOption) (*decoder, error)

NewDecoder wraps a given .c1z file io.Reader and returns an io.Reader for the underlying decoded/uncompressed file.

func ReadHeader

func ReadHeader(reader io.Reader) error

ReadHeader reads len(C1ZFileHeader) bytes from the given io.Reader and compares them to C1ZFileHeader, returning an error if they don't match. If possible, ReadHeader will Seek() to the start of the stream before checking the header bytes. On return, the reader will be pointing to the first byte after the header.

Types

type C1File

type C1File struct {
	// contains filtered or unexported fields
}

func NewC1File

func NewC1File(ctx context.Context, dbFilePath string) (*C1File, error)

Returns a C1File instance for the given db filepath.

func NewC1ZFile

func NewC1ZFile(ctx context.Context, outputFilePath string) (*C1File, error)

Returns a new C1File instance with its state stored at the provided filename.

func (*C1File) CheckpointSync

func (c *C1File) CheckpointSync(ctx context.Context, syncToken string) error

func (*C1File) Close

func (c *C1File) Close() error

Close ensures that the sqlite database is flushed to disk, and if any changes were made we update the original database with our changes.

func (*C1File) CurrentSyncStep

func (c *C1File) CurrentSyncStep(ctx context.Context) (string, error)

func (*C1File) EndSync

func (c *C1File) EndSync(ctx context.Context) error

EndSync updates the current sync_run row with the end time, and removes any other objects that don't have the current sync ID.

func (*C1File) GetAsset

func (c *C1File) GetAsset(ctx context.Context, request *v2.AssetServiceGetAssetRequest) (string, io.Reader, error)

GetAsset fetches the specified asset from the database, and returns the content type and an io.Reader for the caller to read the asset from.

func (*C1File) GetGrant

func (*C1File) LatestSyncID

func (c *C1File) LatestSyncID(ctx context.Context) (string, error)

func (*C1File) PreviousSyncID

func (c *C1File) PreviousSyncID(ctx context.Context) (string, error)

func (*C1File) PutAsset

func (c *C1File) PutAsset(ctx context.Context, assetRef *v2.AssetRef, contentType string, data []byte) error

PutAsset stores the given asset in the database.

func (*C1File) PutEntitlement

func (c *C1File) PutEntitlement(ctx context.Context, entitlement *v2.Entitlement) error

func (*C1File) PutGrant

func (c *C1File) PutGrant(ctx context.Context, grant *v2.Grant) error

func (*C1File) PutResource

func (c *C1File) PutResource(ctx context.Context, resource *v2.Resource) error

func (*C1File) PutResourceType

func (c *C1File) PutResourceType(ctx context.Context, resourceType *v2.ResourceType) error

func (*C1File) StartSync

func (c *C1File) StartSync(ctx context.Context) (string, bool, error)

StartSync generates a sync ID to be associated with all objects discovered during this run.

func (*C1File) Stats

func (c *C1File) Stats(ctx context.Context) (map[string]int64, error)

Stats introspects the database and returns the count of objects for the given sync run.

func (*C1File) ViewSync

func (c *C1File) ViewSync(ctx context.Context, syncID string) error

type DecoderOption

type DecoderOption func(*decoderOptions) error

DecoderOption is an option for creating a decoder.

func WithContext

func WithContext(ctx context.Context) DecoderOption

WithContext sets a context, when cancelled, will cause subequent calls to Read() to return ctx.Error().

func WithDecoderMaxDecodedSize

func WithDecoderMaxDecodedSize(n uint64) DecoderOption

WithDecoderMaxDecodedSize sets the maximum size of the decoded stream. This can be used to cap the resulting decoded stream size. Maximum is 1 << 63 bytes. Default is 2GiB.

func WithDecoderMaxMemory

func WithDecoderMaxMemory(n uint64) DecoderOption

WithDecoderMaxMemory sets the maximum window size for streaming operations. This can be used to control memory usage of potentially hostile content. Maximum is 1 << 63 bytes. Default is 32MiB.

Jump to

Keyboard shortcuts

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