common

package
v0.0.0-...-711d027 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// binary paths (can be overridden by ldflags)
	NixBin      = "nix"
	GzipBin     = "gzip"
	XzBin       = "xz"
	FilefragBin = "filefrag"

	// replaced by ldflags
	Version = "dev"

	// Context for signatures
	ManifestContext     = "styx-manifest-1"
	DaemonParamsContext = "styx-daemon-params-1"

	DigestAlgo = "sha256"
)

Functions

func AppendBlocksList

func AppendBlocksList(blocks []uint16, size int64, blockShift, chunkShift shift.Shift) []uint16

func DefaultChunkShift

func DefaultChunkShift(fileSize int64) shift.Shift

func IsContextError

func IsContextError(err error) bool

func LoadFromFileOrHttpUrl

func LoadFromFileOrHttpUrl(urlString string) ([]byte, error)

func LoadPubKeys

func LoadPubKeys(keys []string) ([]signature.PublicKey, error)

func LoadSecretKeys

func LoadSecretKeys(keyfiles []string) ([]signature.SecretKey, error)

func NormalizeUpstream

func NormalizeUpstream(u *string)

func SignInlineMessage

func SignInlineMessage(keys []signature.SecretKey, context string, msg proto.Message) ([]byte, error)

func SignMessageAsEntry

func SignMessageAsEntry(keys []signature.SecretKey, params *pb.GlobalParams, e *pb.Entry) ([]byte, error)

func TruncU16

func TruncU16[L ~int | ~int32 | ~int64 | ~uint | ~uint16 | ~uint32 | ~uint64](v L) uint16

func TruncU32

func TruncU32[L ~int | ~int64 | ~uint | ~uint32 | ~uint64](v L) uint32

func TruncU64

func TruncU64[L ~int | ~int64 | ~uint | ~uint64](v L) uint64

func TruncU8

func TruncU8[L ~int | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64](v L) uint8

func ValOrErr

func ValOrErr[T any](v T, err error) (T, error)

func VerifyInlineMessage

func VerifyInlineMessage(
	keys []signature.PublicKey,
	expectedContext string,
	b []byte,
	msg proto.Message,
) error

Embedded message must be inline in entry.

func VerifyMessageAsEntry

func VerifyMessageAsEntry(keys []signature.PublicKey, expectedContext string, b []byte) (*pb.Entry, *pb.GlobalParams, error)

Types

type ChunkPool

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

func NewChunkPool

func NewChunkPool() *ChunkPool

func (*ChunkPool) Get

func (cp *ChunkPool) Get(size int) []byte

func (*ChunkPool) Put

func (cp *ChunkPool) Put(b []byte)

type HttpError

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

func NewHttpError

func NewHttpError(code int, body string) HttpError

func (HttpError) Body

func (e HttpError) Body() string

func (HttpError) Code

func (e HttpError) Code() int

func (HttpError) Error

func (e HttpError) Error() string

type SimpleSyncMap

type SimpleSyncMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewSimpleSyncMap

func NewSimpleSyncMap[K comparable, V any]() *SimpleSyncMap[K, V]

func (*SimpleSyncMap[K, V]) Del

func (ssm *SimpleSyncMap[K, V]) Del(k K)

func (*SimpleSyncMap[K, V]) Get

func (ssm *SimpleSyncMap[K, V]) Get(k K) (V, bool)

func (*SimpleSyncMap[K, V]) Put

func (ssm *SimpleSyncMap[K, V]) Put(k K, v V)

func (*SimpleSyncMap[K, V]) PutIfNotPresent

func (ssm *SimpleSyncMap[K, V]) PutIfNotPresent(k K, v V) bool

type ZstdCtxPool

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

func GetZstdCtxPool

func GetZstdCtxPool() *ZstdCtxPool

func (*ZstdCtxPool) Get

func (z *ZstdCtxPool) Get() zstd.Ctx

func (*ZstdCtxPool) Put

func (z *ZstdCtxPool) Put(c zstd.Ctx)

Directories

Path Synopsis
Package errgroup provides synchronization, error propagation, and Context cancelation for groups of goroutines working on subtasks of a common task.
Package errgroup provides synchronization, error propagation, and Context cancelation for groups of goroutines working on subtasks of a common task.

Jump to

Keyboard shortcuts

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