Documentation
¶
Index ¶
- Constants
- Variables
- func MetricsHandler(src promWriter) http.Handler
- func MmapFile(path string) ([]byte, *os.File, error)
- func MunmapFile(data []byte, f *os.File)
- func ParsePublicKey(b64 string) (ed25519.PublicKey, error)
- func SignArtifact(priv ed25519.PrivateKey, kid, stashID string, digest []byte) string
- func ValidateFile(path string) error
- type BuildStats
- type Builder
- func (b *Builder) Add(key, value []byte, line int) error
- func (b *Builder) BuildFrom(ctx context.Context, src io.Reader, format Format) error
- func (b *Builder) BuildFromCSV(csvPath string) error
- func (b *Builder) BuildFromFile(path string) error
- func (b *Builder) BuildFromNDJSON(jsonPath string) error
- func (b *Builder) Close() error
- func (b *Builder) Compile(outPath string) error
- func (b *Builder) CompileFile(ctx context.Context, outPath string) (BuildStats, error)
- func (b *Builder) CompileTo(w io.Writer) (BuildStats, error)
- func (b *Builder) CompileToContext(ctx context.Context, w io.Writer) (BuildStats, error)
- func (b *Builder) CompileV1(outPath string) error
- func (b *Builder) CompileWithOptions(outPath string, opts CompileOptions) error
- func (b *Builder) Grow(n int)
- func (b *Builder) Len() int
- func (b *Builder) Reset()
- type CompileOptions
- type Compression
- type Config
- type DuplicateKeyError
- type FeatureError
- type Field
- type FieldType
- type Format
- type LatencyBucket
- type LatencySnapshot
- type LimitError
- type MalformedRowError
- type Map
- func (m *Map) Close() error
- func (m *Map) DrainLatency() LatencySnapshot
- func (m *Map) FormatVersion() uint32
- func (m *Map) Get(key []byte) ([]byte, error)
- func (m *Map) GetCopy(key, dst []byte) ([]byte, error)
- func (m *Map) GetMany(keys [][]byte, out [][]byte) (int, error)
- func (m *Map) GetString(key string) (string, error)
- func (m *Map) LatencyBuckets() []LatencyBucket
- func (m *Map) Len() int
- func (m *Map) Lookups() uint64
- func (m *Map) Misses() uint64
- func (m *Map) PendingRetired() int
- func (m *Map) Reload(path string) error
- func (m *Map) Scan(fn func(key, value []byte) bool)
- func (m *Map) Size() int64
- func (m *Map) Slots() uint64
- func (m *Map) Swaps() uint64
- func (m *Map) View(key []byte, fn func(value []byte)) error
- func (m *Map) WritePrometheus(w io.Writer)
- type OpenConfig
- type Option
- func WithAPIKey(key string) Option
- func WithBaseURL(url string) Option
- func WithCacheDir(dir string) Option
- func WithCompression(on bool) Option
- func WithHTTPClient(c *http.Client) Option
- func WithLogger(l *log.Logger) Option
- func WithNodeID(id string) Option
- func WithOpenConfig(cfg OpenConfig) Option
- func WithSignatureKeys(keys map[string]ed25519.PublicKey) Option
- func WithSyncInterval(d time.Duration) Option
- func WithTelemetryAPIKey(key string) Option
- func WithTelemetryBaseURL(url string) Option
- func WithTelemetryDisabled() Option
- func WithTelemetryInterval(d time.Duration) Option
- type Schema
- func (sc *Schema) Bool(v []byte, name string) (bool, error)
- func (sc *Schema) Bytes(v []byte, name string) ([]byte, error)
- func (sc *Schema) Encode(vals ...any) ([]byte, error)
- func (sc *Schema) Float(v []byte, name string) (float64, error)
- func (sc *Schema) Int(v []byte, name string) (int64, error)
- func (sc *Schema) String(v []byte, name string) (string, error)
- func (sc *Schema) Uint(v []byte, name string) (uint64, error)
- type StatusError
- type Synchronizer
- func (s *Synchronizer) Close() error
- func (s *Synchronizer) DatasetName() stringdeprecated
- func (s *Synchronizer) ETag() string
- func (s *Synchronizer) FlushTelemetry() error
- func (s *Synchronizer) Get(key []byte) ([]byte, error)
- func (s *Synchronizer) GetCopy(key, dst []byte) ([]byte, error)
- func (s *Synchronizer) GetString(key string) (string, error)
- func (s *Synchronizer) Map() *Map
- func (s *Synchronizer) NodeID() string
- func (s *Synchronizer) StashName() string
- func (s *Synchronizer) Sync(ctx context.Context) error
- func (s *Synchronizer) TelemetryEnabled() bool
- func (s *Synchronizer) TelemetryStats() TelemetryStats
- func (s *Synchronizer) View(key []byte, fn func([]byte)) error
- func (s *Synchronizer) WritePrometheus(w io.Writer)
- type TelemetryStats
- type VersionError
- type WarmMode
Constants ¶
const ( // MaxKeyLen is the largest key (in bytes) a v1 blob can store. MaxKeyLen = 65535 // MaxValueLen is the largest value (in bytes) a v1 blob can store. MaxValueLen = 1 << 20 )
const ( DefaultSyncInterval = 30 * time.Second QuotaPause = 5 * time.Minute MaxRetryAfter = time.Hour )
Sync protocol constants (CONTRACTS.md §4). The default poll interval is the same in the Go, Rust and Java SDKs.
const DefaultRetireGrace = 2 * time.Second
DefaultRetireGrace is the default zero-copy validity window after a swap.
const (
DefaultTelemetryInterval = 60 * time.Second
)
const SignatureHeader = "X-Attos-Signature"
SignatureHeader is the response header carrying the detached signature.
const Version = "1.4.0"
Version is the attos-go SDK version reported in User-Agent and telemetry.
Variables ¶
var ( ErrKeyNotFound = errors.New("key not found") ErrCorruptedBinary = errors.New("corrupted binary") ErrInvalidMagic = errors.New("invalid magic bytes") ErrInvalidVersion = errors.New("invalid version") // ErrUnsupportedFeature is returned (via *FeatureError) for a well-formed file that uses a // format feature newer than this SDK knows. The fix is to upgrade the SDK. ErrUnsupportedFeature = errors.New("unsupported format feature") ErrChecksumMismatch = errors.New("checksum mismatch") ErrMapClosed = errors.New("map closed") ErrMlockFailed = errors.New("mlock failed") // ErrNoMap is returned by Synchronizer lookups before the first blob is loaded. ErrNoMap = errors.New("no blob loaded") )
Reader / runtime errors (CONTRACTS.md §1.6).
var ( ErrMissingValueColumn = errors.New("missing attos_value column") ErrNoDimensions = errors.New("no dimension columns") ErrBlobTooLarge = errors.New("blob too large") ErrUnplaceable = errors.New("unplaceable bucket") ErrMalformedRow = errors.New("malformed row") ErrDuplicateKey = errors.New("duplicate key") ErrLimit = errors.New("size limit exceeded") )
Builder errors (CONTRACTS.md §1.5 / §3). Typed errors unwrap to these.
var ( // ErrSignatureMissing: signing is enforced but the response carried no signature. ErrSignatureMissing = errors.New("attos: dataset signature missing") // ErrSignatureInvalid: the signature is malformed, names an unknown key or does not verify. ErrSignatureInvalid = errors.New("attos: dataset signature invalid") )
var ErrBatchOutTooSmall = errors.New("batch output slice shorter than keys")
ErrBatchOutTooSmall is returned by GetMany when out is shorter than keys.
var ErrSchema = errors.New("typed value does not match schema")
ErrSchema is returned for values that do not fit their Schema.
var ErrTruncatedDownload = errors.New("attos sync: truncated download")
ErrTruncatedDownload is returned when the body is shorter than Content-Length.
Functions ¶
func MetricsHandler ¶
MetricsHandler serves the Prometheus exposition of a *Map or *Synchronizer, for example http.Handle("/metrics", attos.MetricsHandler(sync)).
func MunmapFile ¶
MunmapFile releases a mapping returned by MmapFile. Deprecated.
func ParsePublicKey ¶
ParsePublicKey decodes a base64 (standard or URL-safe, padded or not) Ed25519 public key.
func SignArtifact ¶
func SignArtifact(priv ed25519.PrivateKey, kid, stashID string, digest []byte) string
SignArtifact signs a file digest the way the control plane does (for tests and tooling).
func ValidateFile ¶
ValidateFile fully validates a blob on disk (magic, version, flag, size arithmetic and CRC32) without keeping it mapped. This is the validation the sync path applies before publishing a downloaded blob.
Types ¶
type BuildStats ¶
type BuildStats struct {
Rows uint64 // n
Slots uint64 // S
Buckets uint64 // B
MaxDisplacement uint32
Bytes int64 // bytes written, including the CRC trailer
CRC32 uint32
}
BuildStats describes a compiled blob.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder accumulates (key, value) rows and compiles them into a v1 blob. A Builder is not safe for concurrent use.
func NewSpillBuilder ¶
NewSpillBuilder returns a Builder that stores row data in a temporary file under dir ("" means os.TempDir) and keeps only a small index in memory. Output is byte-for-byte identical to NewBuilder. Call Close when done to remove the temporary file.
func (*Builder) Add ¶
Add appends one row. line is used only for error reporting (use 0 if unknown). Add does not check for duplicates until the next BuildFrom or Compile call.
func (*Builder) BuildFrom ¶
BuildFrom parses src in the given format and adds its rows. On any error the Builder is left exactly as it was before the call. Line numbers in errors are 1-based physical line numbers within src.
Error precedence matches the reference implementation: a parse error anywhere in src wins; otherwise the earliest row that exceeds a size limit or repeats an earlier key is reported.
func (*Builder) BuildFromCSV ¶
BuildFromCSV parses an RFC 4180 CSV file (header row required) and adds its rows.
func (*Builder) BuildFromFile ¶
BuildFromFile parses a CSV or NDJSON file, detecting the format (§1.5).
func (*Builder) BuildFromNDJSON ¶
BuildFromNDJSON parses an NDJSON file and adds its rows.
func (*Builder) Close ¶
Close releases the temporary file of a spilling Builder. It is a no-op for NewBuilder builders.
func (*Builder) Compile ¶
Compile writes a version 2 (.attos) file without compression. See CompileWithOptions.
func (*Builder) CompileFile ¶
CompileFile is Compile with cancellation and statistics.
func (*Builder) CompileTo ¶
func (b *Builder) CompileTo(w io.Writer) (BuildStats, error)
CompileTo writes the v1 blob for all accumulated rows to w. Nothing is written if duplicate detection or placement fails.
func (*Builder) CompileToContext ¶
CompileToContext is CompileTo with cancellation (checked every 64k rows / buckets and during placement). On cancellation nothing has been written.
func (*Builder) CompileV1 ¶
Compile writes the blob to outPath atomically: it writes a temporary file in the same directory, fsyncs it and renames it over outPath. On error outPath is untouched and the temporary file is removed. CompileV1 writes the legacy hash-and-displace format (version 1). Kept for compatibility and tests; new datasets should use Compile.
func (*Builder) CompileWithOptions ¶
func (b *Builder) CompileWithOptions(outPath string, opts CompileOptions) error
CompileWithOptions writes a version 2 (.attos) file: a PTHash minimal perfect hash, an offset table and the key-prefixed records stored in slot order, optionally in LZ4 blocks. See FORMAT_V2.md.
func (*Builder) Grow ¶
Grow preallocates the row index for n more rows. It avoids the transient garbage of repeated slice growth when the row count is known in advance (about 26 bytes per row).
type CompileOptions ¶
type CompileOptions struct {
Compression Compression
// BlockSize is the number of records per compressed block: a power of two from 1 to 256.
// Smaller blocks decompress faster but compress less. Default 8.
BlockSize int
// OffsetWidth is the byte width of the offsets section: 0 chooses automatically (4 when the blob is at
// most 2^32-1 bytes, else 5), 4 forces 32-bit offsets, 5 forces 40-bit offsets (blobs up to 1 TiB).
OffsetWidth int
// FingerprintBytes selects lean keys: 0 stores full keys (default); 4 or 8 stores only a fingerprint
// of that many bytes per record instead of the key (records are fingerprint|value). Lookups verify the
// fingerprint, so a key that was never added is accepted with probability 2^-32 (4) or 2^-64 (8).
// Scan then yields the fingerprint in place of the key. See FORMAT_V2.md.
FingerprintBytes int
}
CompileOptions tunes Compile. The zero value means no compression.
type Compression ¶
type Compression int
Compression selects how records are stored in a version 2 file.
const ( // CompressNone stores records uncompressed: fastest lookups, zero allocations per Get. CompressNone Compression = iota // CompressLZ4 stores records in small LZ4-compressed blocks. Smaller files, but every lookup // decompresses one block (roughly 0.4 microseconds per record in the block) and allocates. See FORMAT_V2.md. CompressLZ4 )
type Config ¶
type Config struct {
TelemetryEnabled bool `json:"telemetry_enabled"`
}
Config is the server-provided SDK configuration (X-Attos-Config header).
type DuplicateKeyError ¶
type DuplicateKeyError struct {
FirstLine, Line int
Key string // the duplicated key, truncated to 64 bytes (may be empty)
}
DuplicateKeyError reports a key that appears more than once.
func (*DuplicateKeyError) Error ¶
func (e *DuplicateKeyError) Error() string
func (*DuplicateKeyError) Unwrap ¶
func (e *DuplicateKeyError) Unwrap() error
type FeatureError ¶
type FeatureError struct{ Feature string }
FeatureError is returned when a file passes its CRC but uses a format feature this SDK does not implement (an unknown flag bit, offset width or fingerprint width). It matches ErrUnsupportedFeature with errors.Is. Fail-closed: the file is never partially read.
func (*FeatureError) Error ¶
func (e *FeatureError) Error() string
func (*FeatureError) Unwrap ¶
func (e *FeatureError) Unwrap() error
type LatencyBucket ¶
LatencyBucket is one cumulative histogram bucket: Count samples with a latency of at most UpperNs nanoseconds that were not counted in a lower bucket.
type LatencySnapshot ¶
LatencySnapshot summarises sampled lookup latencies.
type LimitError ¶
LimitError reports a key or value longer than the v1 format allows.
func (*LimitError) Error ¶
func (e *LimitError) Error() string
func (*LimitError) Unwrap ¶
func (e *LimitError) Unwrap() error
type MalformedRowError ¶
MalformedRowError reports a row that cannot be parsed. Line is the 1-based physical line number (the CSV header is line 1).
func (*MalformedRowError) Error ¶
func (e *MalformedRowError) Error() string
func (*MalformedRowError) Unwrap ¶
func (e *MalformedRowError) Unwrap() error
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is a read-only, memory-mapped Attos blob that can be hot-swapped. All methods are safe for concurrent use. Lookups are lock-free and allocation-free.
func OpenWithConfig ¶
func OpenWithConfig(path string, cfg OpenConfig) (*Map, error)
OpenWithConfig maps path read-only, validates it and returns a Map. Every failure mode returns a typed error: ErrInvalidMagic, ErrInvalidVersion (*VersionError), ErrCorruptedBinary or ErrChecksumMismatch.
func (*Map) Close ¶
Close stops all further lookups (they return ErrMapClosed), waits for in-flight lookups to finish and unmaps every mapping, including retired ones still in their grace period. Zero-copy values become invalid when Close returns. Close is idempotent.
func (*Map) DrainLatency ¶
func (m *Map) DrainLatency() LatencySnapshot
DrainLatency returns sampled lookup-latency percentiles since the previous call and resets the histogram (used by the telemetry reporter).
func (*Map) FormatVersion ¶
FormatVersion returns the file format version of the live mapping (1 or 2), or 0 if no file is loaded.
func (*Map) Get ¶
Get performs an O(1) lookup and returns a zero-copy slice of the value. See the package comment above for the validity window; use GetCopy or View to keep the value longer. Zero allocations.
func (*Map) GetCopy ¶
GetCopy looks up key and appends its value to dst, returning the extended slice. The result never aliases the mapping and stays valid across swaps and Close. Zero allocations when cap(dst) is large enough.
func (*Map) GetMany ¶
GetMany looks up keys in one call and stores each zero-copy value in out[i] (nil when the key is absent). It returns the number of keys found. len(out) must be at least len(keys). Value slices have the same validity window as Get.
It is cheaper per key than repeated Get on large files: the mapping is pinned once, and for each group of keys the routing-table reads are issued together, then the offset-table reads, so their cache misses overlap instead of stalling one after another. Every key counts as a lookup (absent keys as misses); batch calls are not latency-sampled. Zero allocations.
func (*Map) GetString ¶
GetString performs an O(1) lookup returning a zero-copy string with the same validity window as Get. Zero allocations.
func (*Map) LatencyBuckets ¶
func (m *Map) LatencyBuckets() []LatencyBucket
LatencyBuckets returns the sampled lookup-latency histogram (1 in 256 lookups) as non-empty buckets in ascending order. Unlike DrainLatency it is never reset, so exporters can read it at any time.
func (*Map) Misses ¶
Misses returns the number of lookups that found no value. Hits are Lookups() - Misses().
func (*Map) PendingRetired ¶
PendingRetired returns the number of replaced mappings not yet unmapped.
func (*Map) Reload ¶
Reload opens and validates path (honouring the Map's OpenConfig) and atomically hot-swaps it in. In-flight lookups finish on the old mapping, which is unmapped after they drain plus RetireGrace. Reload blocks while two retired mappings are still pending. On error the current map is kept.
func (*Map) Scan ¶
Scan iterates over all entries in slot order (arbitrary, MPHF-defined). The mapping is pinned for the whole scan; key and value slices are valid only during the callback. Return false to stop early.
func (*Map) View ¶
View looks up key and calls fn with a zero-copy value. The mapping is pinned for the duration of fn, so the slice is valid until fn returns (fn must not retain it, call Close or block on a swap).
func (*Map) WritePrometheus ¶
WritePrometheus writes the Prometheus text exposition (version 0.0.4) for the map: lookups, misses and hit ratio, hot swaps, file size and version, and a sampled lookup-latency histogram (1 in 256 lookups). Everything is read from counters the SDK keeps anyway, so scraping adds nothing to the lookup path.
type OpenConfig ¶
type OpenConfig struct {
// PinToMemory calls mlock(2) after mapping to prevent the OS from
// paging out the region. Recommended for latency-critical deployments
// (GKE Standard supports mlock; Autopilot does not).
// Default: false. Failure is non-fatal; a warning is emitted via Logger.
PinToMemory bool
// ValidateChecksum verifies the CRC32-IEEE trailer before the map is
// exposed. The Synchronizer always validates downloaded blobs regardless
// of this flag. Default: false (direct Open only).
ValidateChecksum bool
// WarmUp reads every page right after mapping so the first lookups never fault. It makes the whole
// file resident, so resident memory equals the file size. Default: false: only the pages lookups
// actually touch stay in memory (with MADV_RANDOM, no readahead).
WarmUp bool
// Warm selects how much of the file is read in at open: WarmNone (default) maps lazily, so only the
// pages lookups touch become resident; WarmIndex reads the header, hash tables and offset table
// (about 2-4% of the file) so a lookup against a cold page cache faults in one record page instead
// of three; WarmFull reads every page (same as WarmUp: true).
Warm WarmMode
// SkipWarmUp is deprecated and has no effect unless WarmUp is set, in which case it wins.
SkipWarmUp bool
// RetireGrace is the minimum time a replaced map stays mapped after a hot
// swap (in addition to waiting for in-flight lookups to finish). It bounds
// the validity window of zero-copy values returned by Get/GetString: such
// a value stays readable for at least RetireGrace after the map it came
// from was replaced. Default (0): DefaultRetireGrace. Negative: no grace.
RetireGrace time.Duration
// Logger is used for non-fatal operational messages (mlock failures,
// warm-up, etc.). If nil, log.Default() is used.
Logger *log.Logger
// LocalObjectStore instructs the Synchronizer to pull directly from a
// customer S3 bucket instead of polling the Attos control plane.
LocalObjectStore bool
// LocalS3Bucket is the name of the customer's S3 bucket to pull from
// when LocalObjectStore is true. The object key is "<stashID>.attos".
LocalS3Bucket string
}
OpenConfig controls how a Map is opened and validated. All fields are optional; zero values select safe defaults.
type Option ¶
type Option func(*Synchronizer)
Option configures the Attos Synchronizer.
func WithAPIKey ¶
WithAPIKey sets the API key sent in X-API-Key on sync and telemetry requests.
func WithBaseURL ¶
WithBaseURL sets the control plane base URL. Default: "http://localhost:8080".
func WithCacheDir ¶
WithCacheDir sets the directory holding the live blob (<stashID>.attos), its ETag and in-progress downloads (always in the same directory, so the final rename is atomic). Default: "./.attos/cache".
func WithCompression ¶
WithCompression controls whether syncs ask for the gzip copy of the blob (Accept-Encoding: gzip; default true). Compression is transport-only: the stored and memory-mapped blob is always the v1 file.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client used for sync and telemetry.
func WithLogger ¶
WithLogger injects a custom *log.Logger for all operational messages emitted by the Synchronizer (sync errors, hot-swap events, telemetry failures). If not set, log.Default() is used.
func WithNodeID ¶
WithNodeID overrides the X-Attos-Node-ID (1–128 chars). Default: the ATTOS_NODE_ID environment variable, else the hostname, else a random UUIDv4.
Active nodes are counted (and billed) by distinct node ID, so every process on one host counts as one node by default; containers sharing a hostname are one node too. Set a distinct ID per process if they should count separately.
func WithOpenConfig ¶
func WithOpenConfig(cfg OpenConfig) Option
WithOpenConfig sets the OpenConfig for the Synchronizer.
func WithSignatureKeys ¶
WithSignatureKeys enforces signed artifacts: only files whose signature verifies against one of these public keys (by key id) are installed.
func WithSyncInterval ¶
WithSyncInterval sets the background polling interval. A value of 0 disables background polling (manual Sync calls only). Default: DefaultSyncInterval (30 s), identical across the Go, Rust and Java SDKs.
func WithTelemetryAPIKey ¶
WithTelemetryAPIKey uses a different API key for telemetry than for sync.
func WithTelemetryBaseURL ¶
WithTelemetryBaseURL sends telemetry to a different base URL than sync.
func WithTelemetryDisabled ¶
func WithTelemetryDisabled() Option
WithTelemetryDisabled turns the telemetry emitter off regardless of the server's X-Attos-Config.
func WithTelemetryInterval ¶
WithTelemetryInterval sets the telemetry report interval (default 60 s). 0 disables the telemetry emitter.
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema describes a structured value (a client-side convention; the file format is unchanged). Fields are laid out in declaration order; integers and floats are big-endian, Bool is one byte (0 or 1), String and Bytes are a u16 big-endian length followed by the content. The Rust and Java SDKs use the same layout.
func (*Schema) Encode ¶
Encode builds a value from vals in declaration order: uint64/int64/float64/ bool/string/[]byte (any integer or float kind is accepted for numeric fields).
type StatusError ¶
type StatusError struct {
Code int
RetryAfter time.Duration // parsed Retry-After for 402/429 (0 if absent)
Body string
}
StatusError is returned by Sync for a non-200/304 HTTP response.
func (*StatusError) Error ¶
func (e *StatusError) Error() string
func (*StatusError) Quota ¶
func (e *StatusError) Quota() bool
Quota reports whether the error is a node/quota limit (402 or 429).
type Synchronizer ¶
type Synchronizer struct {
// contains filtered or unexported fields
}
Synchronizer is the data-plane SDK for syncing and querying binary blobs locally. It manages the full lifecycle: download, validation, mmap, atomic hot-swap, background polling with back-off, telemetry and shutdown.
Lookups (Get, GetString, GetCopy, View) are lock-free and allocation-free; see Map for the retirement scheme and the zero-copy validity window.
func NewSynchronizer ¶
NewSynchronizer creates and initialises a Synchronizer for stashID.
It first loads a previously synced blob from the cache directory (if one exists and validates), then performs an initial Sync. If that sync fails but a cached blob is loaded, the error is logged and the cached data is served; with no data at all the error is returned. Background polling runs every WithSyncInterval (default DefaultSyncInterval; 0 disables polling).
func (*Synchronizer) Close ¶
func (s *Synchronizer) Close() error
Close stops background polling and telemetry, waits for them to exit, then closes the map (waiting for in-flight lookups and unmapping every region). It is safe to call more than once.
func (*Synchronizer) DatasetName
deprecated
func (s *Synchronizer) DatasetName() string
DatasetName returns the stash's display name.
Deprecated: datasets are now called stashes; use StashName.
func (*Synchronizer) ETag ¶
func (s *Synchronizer) ETag() string
ETag returns the ETag of the currently loaded blob ("" if unknown).
func (*Synchronizer) FlushTelemetry ¶
func (s *Synchronizer) FlushTelemetry() error
FlushTelemetry builds and enqueues a report immediately (testing/diagnostics).
func (*Synchronizer) Get ¶
func (s *Synchronizer) Get(key []byte) ([]byte, error)
Get performs an O(1) lock-free, allocation-free lookup. The returned slice aliases the mapping (validity window: see Map). Use GetCopy to keep it.
func (*Synchronizer) GetCopy ¶
func (s *Synchronizer) GetCopy(key, dst []byte) ([]byte, error)
GetCopy appends the value for key to dst (safe to keep across swaps).
func (*Synchronizer) GetString ¶
func (s *Synchronizer) GetString(key string) (string, error)
GetString is the zero-copy string variant of Get.
func (*Synchronizer) Map ¶
func (s *Synchronizer) Map() *Map
Map returns the hot-swappable map handle served by this Synchronizer.
func (*Synchronizer) NodeID ¶
func (s *Synchronizer) NodeID() string
NodeID returns the X-Attos-Node-ID sent by this process.
func (*Synchronizer) StashName ¶
func (s *Synchronizer) StashName() string
StashName returns the stash's display name as sent by the control plane (the X-Dataset-Name header, "" if none).
func (*Synchronizer) Sync ¶
func (s *Synchronizer) Sync(ctx context.Context) error
Sync performs one sync attempt: conditional GET (If-None-Match), and on 200 download → fsync → validate → rename → mmap → atomic publish. On any failure the current map keeps serving. It does not sleep or retry; the background loop applies the back-off policy.
func (*Synchronizer) TelemetryEnabled ¶
func (s *Synchronizer) TelemetryEnabled() bool
TelemetryEnabled reports the server-provided telemetry switch.
func (*Synchronizer) TelemetryStats ¶
func (s *Synchronizer) TelemetryStats() TelemetryStats
TelemetryStats returns the emitter counters (zero if telemetry is off).
func (*Synchronizer) View ¶
func (s *Synchronizer) View(key []byte, fn func([]byte)) error
View calls fn with a zero-copy value while the mapping is pinned.
func (*Synchronizer) WritePrometheus ¶
func (s *Synchronizer) WritePrometheus(w io.Writer)
WritePrometheus writes the map metrics plus sync state: the ETag and stash of the file in use, CRC failures, sync outcomes and telemetry delivery.
type TelemetryStats ¶
TelemetryStats exposes emitter counters (for tests and diagnostics).
type VersionError ¶
type VersionError struct{ Version uint32 }
VersionError is returned when a blob carries an unsupported version. It matches ErrInvalidVersion with errors.Is.
func (*VersionError) Error ¶
func (e *VersionError) Error() string
func (*VersionError) Unwrap ¶
func (e *VersionError) Unwrap() error
type WarmMode ¶
type WarmMode int
WarmMode selects how much of a file OpenConfig reads in at open.
const ( // WarmNone maps the file lazily. Lowest resident memory; a lookup against a cold page cache pays // one disk read per page it touches until the working set is cached. WarmNone WarmMode = iota // WarmIndex reads in everything before the record data: header, hash tables and offset table. WarmIndex // WarmFull reads in the whole file. Resident memory equals the file size. WarmFull )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
attos-size
command
Command attos-size estimates what a dataset costs to serve from Attos compared with Redis: it samples your data (a CSV in Attos input format, a key,value CSV export, or a live Redis read-only), builds real Attos files from the sample, and prints the projected file sizes, RAM saved and the equivalent Redis monthly cost.
|
Command attos-size estimates what a dataset costs to serve from Attos compared with Redis: it samples your data (a CSV in Attos input format, a key,value CSV export, or a live Redis read-only), builds real Attos files from the sample, and prints the projected file sizes, RAM saved and the equivalent Redis monthly cost. |
|
internal
|
|
|
lz4
Package lz4 is a small, dependency-free implementation of the LZ4 block format (https://github.com/lz4/lz4/blob/dev/doc/lz4_Block_format.md): a greedy compressor used when the SDK builds compressed .attos files, and a bounds-checked decompressor used by readers.
|
Package lz4 is a small, dependency-free implementation of the LZ4 block format (https://github.com/lz4/lz4/blob/dev/doc/lz4_Block_format.md): a greedy compressor used when the SDK builds compressed .attos files, and a bounds-checked decompressor used by readers. |
|
pthash
Package pthash implements the minimal perfect hash used by the .attos v2 format (PTHash, Pibiri & Trani 2021, "dual compact" pilot encoding).
|
Package pthash implements the minimal perfect hash used by the .attos v2 format (PTHash, Pibiri & Trani 2021, "dual compact" pilot encoding). |