common

package
v0.0.0-...-c1ecf52 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// Context for signatures
	ManifestContext     = "styx-manifest-1"
	DaemonParamsContext = "styx-daemon-params-1"
)
View Source
const (
	CTHdr   = "Content-Type"
	CTJson  = "application/json"
	CTProto = "application/protobuf"
)

Variables

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

	// replaced by ldflags
	Version = "dev"
)

Functions

func AppendBlocksList

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

func ContiguousBytes

func ContiguousBytes(in [][]byte) []byte

func DefaultChunkShift

func DefaultChunkShift(fileSize int64) shift.Shift

func IsContextError

func IsContextError(err error) bool

func IsNotFound

func IsNotFound(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 RetryHttpRequest

func RetryHttpRequest(ctx context.Context, method, url, cType string, body []byte) (*http.Response, error)

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 TruncU8

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

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 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 HttpErrorFromRes

func HttpErrorFromRes(res *http.Response) HttpError

note: this does not close res.Body, caller should close it

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

func (HttpError) IsNotFound

func (e HttpError) IsNotFound() bool

type NotFoundable

type NotFoundable interface {
	IsNotFound() bool
}

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]) Delete

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

func (*SimpleSyncMap[K, V]) DeleteFunc

func (ssm *SimpleSyncMap[K, V]) DeleteFunc(f func(K, V) bool)

Deletes entries where f(k, v) returns true.

func (*SimpleSyncMap[K, V]) Get

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

func (*SimpleSyncMap[K, V]) GetOrPut

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

If k is present, returns its value and true, otherwise sets k to v and returns v and false.

func (*SimpleSyncMap[K, V]) Has

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

func (*SimpleSyncMap[K, V]) Modify

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

Atomically calls f with the result of Get(k) and then either sets k to a new value or deletes k.

func (*SimpleSyncMap[K, V]) Put

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

func (*SimpleSyncMap[K, V]) WithValue

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

Calls f on the value of key k, while holding the lock.

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