ordersfile

package
v1.119.0-rc Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: AGPL-3.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// V0 is the first orders file version. It stores orders and limits with no checksum.
	V0 = Version("v0")
	// V1 is the second orders file version. It includes a checksum for each entry so that file corruption is handled better.
	V1 = Version("v1")
)

Variables

View Source
var (
	// Error identifies errors with orders files.
	Error = errs.Class("ordersfile")
	// ErrEntryCorrupt is returned when a corrupt entry is found.
	ErrEntryCorrupt = errs.Class("ordersfile corrupt entry")
)

Functions

func ArchiveFileName

func ArchiveFileName(satelliteID storj.NodeID, creationTime, archiveTime time.Time, status pb.SettlementWithWindowResponse_Status, version Version) string

ArchiveFileName gets the filename of an archived file.

func MoveUnsent

func MoveUnsent(unsentDir, archiveDir string, satelliteID storj.NodeID, createdAtHour, archivedAt time.Time, status pb.SettlementWithWindowResponse_Status, version Version) error

MoveUnsent moves an unsent orders file to the archived orders file directory.

func UnsentFileName

func UnsentFileName(satelliteID storj.NodeID, creationTime time.Time, version Version) string

UnsentFileName gets the filename of an unsent file.

Types

type ArchivedInfo

type ArchivedInfo struct {
	SatelliteID   storj.NodeID
	CreatedAtHour time.Time
	ArchivedAt    time.Time
	StatusText    string
	Version       Version
}

ArchivedInfo contains information relevant to an archived orders file, as well as information necessary to open it for reading.

func GetArchivedInfo

func GetArchivedInfo(filename string) (*ArchivedInfo, error)

GetArchivedInfo returns a new ArchivedInfo which can be used to get information about and read from an archived orders file.

type Info

type Info struct {
	Limit *pb.OrderLimit
	Order *pb.Order
}

Info contains full information about an order.

type Readable

type Readable interface {
	ReadOne() (*Info, error)
	Close() error
}

Readable defines an interface for a read-only orders file.

func OpenReadable

func OpenReadable(path string, version Version) (Readable, error)

OpenReadable opens for reading the unsent or archived orders file at a given path. It assumes the path has already been validated with GetUnsentInfo or GetArchivedInfo.

func OpenReadableV0

func OpenReadableV0(path string) (Readable, error)

OpenReadableV0 opens for reading the unsent or archived orders file at a given path.

func OpenReadableV1

func OpenReadableV1(path string) (Readable, error)

OpenReadableV1 opens for reading the unsent or archived orders file at a given path.

type UnsentInfo

type UnsentInfo struct {
	SatelliteID   storj.NodeID
	CreatedAtHour time.Time
	Version       Version
}

UnsentInfo contains information relevant to an unsent orders file, as well as information necessary to open it for reading.

func GetUnsentInfo

func GetUnsentInfo(filename string) (*UnsentInfo, error)

GetUnsentInfo returns a new UnsentInfo which can be used to get information about and read from an unsent orders file.

type Version

type Version string

Version is a type for defining different file versions.

type Writable

type Writable interface {
	Append(*Info) error
	Close() error
}

Writable defines an interface for a write-only orders file.

func OpenWritableUnsent

func OpenWritableUnsent(unsentDir string, satelliteID storj.NodeID, creationTime time.Time) (Writable, error)

OpenWritableUnsent creates or opens for appending the unsent orders file for a given satellite ID and creation hour.

func OpenWritableV0

func OpenWritableV0(path string) (Writable, error)

OpenWritableV0 opens for writing the unsent or archived orders file at a given path.

func OpenWritableV1

func OpenWritableV1(path string, satelliteID storj.NodeID, creationTime time.Time) (Writable, error)

OpenWritableV1 opens for writing the unsent or archived orders file at a given path. If the file is new, the file header is written.

Jump to

Keyboard shortcuts

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