seqfile

package
v0.0.0-...-522126a Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package seqfile provides dynamic ordered files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSeqFileInode

func NewSeqFileInode(ctx context.Context, source SeqSource, msrc *fs.MountSource) *fs.Inode

NewSeqFileInode returns an Inode with SeqFile InodeOperations.

Types

type SeqData

type SeqData struct {
	// The data to be returned to the user.
	Buf []byte

	// A seek handle used to find the next valid unit in ReadSeqFiledata.
	Handle SeqHandle
}

SeqData holds the data for one unit in the file.

+stateify savable

type SeqFile

type SeqFile struct {
	fsutil.InodeGenericChecker `state:"nosave"`
	fsutil.InodeNoopRelease    `state:"nosave"`
	fsutil.InodeNoopWriteOut   `state:"nosave"`
	fsutil.InodeNotAllocatable `state:"nosave"`
	fsutil.InodeNotDirectory   `state:"nosave"`
	fsutil.InodeNotMappable    `state:"nosave"`
	fsutil.InodeNotSocket      `state:"nosave"`
	fsutil.InodeNotSymlink     `state:"nosave"`
	fsutil.InodeNotTruncatable `state:"nosave"`
	fsutil.InodeVirtual        `state:"nosave"`

	fsutil.InodeSimpleExtendedAttributes
	fsutil.InodeSimpleAttributes

	SeqSource
	// contains filtered or unexported fields
}

SeqFile is used to provide dynamic files that can be ordered by record.

+stateify savable

func NewSeqFile

func NewSeqFile(ctx context.Context, source SeqSource) *SeqFile

NewSeqFile returns a seqfile suitable for use by external consumers.

func (*SeqFile) GetFile

func (s *SeqFile) GetFile(ctx context.Context, dirent *fs.Dirent, flags fs.FileFlags) (*fs.File, error)

GetFile implements fs.InodeOperations.GetFile.

func (*SeqFile) UnstableAttr

func (s *SeqFile) UnstableAttr(ctx context.Context, inode *fs.Inode) (fs.UnstableAttr, error)

UnstableAttr returns unstable attributes of the SeqFile.

type SeqGenerationCounter

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

SeqGenerationCounter is a counter to keep track if the SeqSource should be updated. SeqGenerationCounter is not thread-safe and should be protected with a mutex.

func (*SeqGenerationCounter) Generation

func (s *SeqGenerationCounter) Generation() int64

Generation returns the current generation counter.

func (*SeqGenerationCounter) IsCurrent

func (s *SeqGenerationCounter) IsCurrent(generation int64) bool

IsCurrent returns whether the given generation is current or not.

func (*SeqGenerationCounter) SetGeneration

func (s *SeqGenerationCounter) SetGeneration(generation int64)

SetGeneration sets the generation to the new value, be careful to not set it to a value less than current.

func (*SeqGenerationCounter) Update

func (s *SeqGenerationCounter) Update()

Update increments the current generation.

type SeqHandle

type SeqHandle interface{}

SeqHandle is a helper handle to seek in the file.

type SeqSource

type SeqSource interface {
	// NeedsUpdate returns true if the consumer of SeqData should call
	// ReadSeqFileData again. Generation is the generation returned by
	// ReadSeqFile or 0.
	NeedsUpdate(generation int64) bool

	// Returns a slice of SeqData ordered by unit and the current
	// generation. The first entry in the slice is greater than the handle.
	// If handle is nil then all known records are returned. Generation
	// must always be greater than 0.
	ReadSeqFileData(ctx context.Context, handle SeqHandle) ([]SeqData, int64)
}

SeqSource is a data source for a SeqFile file.

Jump to

Keyboard shortcuts

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