util

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package util provides shared utility functions used across NornicDB packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeMsgpackBytes

func DecodeMsgpackBytes(data []byte, dst any) error

DecodeMsgpackBytes safely decodes msgpack from an in-memory payload with size validation.

func DecodeMsgpackFile

func DecodeMsgpackFile(file *os.File, dst any) error

DecodeMsgpackFile safely decodes msgpack from a file, rejecting oversized payloads.

func HashStringToInt64

func HashStringToInt64(s string) int64

HashStringToInt64 converts a string ID to an int64 for Neo4j Bolt protocol compatibility. NornicDB uses string IDs (UUIDs or custom strings), but Bolt protocol expects int64 IDs. This function uses FNV-1a hash algorithm for deterministic conversion with good distribution.

FNV-1a (Fowler-Noll-Vo) is a fast, non-cryptographic hash function that:

  • Produces deterministic results (same input = same output)
  • Has good distribution (fewer collisions than simple multiplicative hashing)
  • Is fast and suitable for high-frequency operations

The hash uses FNV-1a 64-bit variant with offset basis 14695981039346656037.

Example:

HashStringToInt64("user-123") => 1234567890123456789
HashStringToInt64("user-123") => 1234567890123456789 (same result)

func MaxMsgpackDecodeBytes

func MaxMsgpackDecodeBytes() int64

MaxMsgpackDecodeBytes returns the configured maximum number of bytes accepted for msgpack decode operations.

func ValidateMsgpackPayloadSize

func ValidateMsgpackPayloadSize(size int64) error

ValidateMsgpackPayloadSize rejects payloads larger than the configured cap.

Types

This section is empty.

Jump to

Keyboard shortcuts

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