fn

package
v1.2.13 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package fn assembles and installs the nova-sprint Redis Function library.

Index

Constants

View Source
const Library = "nova_sprint"
View Source
const MaxLocals = 180

MaxLocals is the most active locals the library's main function may hold. Lua (and so Redis) refuses a function with more than 200; the headroom is for the next merge. TestLibraryLocalsUnderLimit enforces it.

View Source
const Prelude = "local NS = {}\n"

Prelude is the one chunk-level local of the assembled library: NS, the table through which a file hands helpers to a file that sorts after it (capacity.lua as NS.capacity, friend_roles.lua as NS.friend_roles).

Variables

View Source
var ListQuery = redis.FunctionListQuery{LibraryNamePattern: Library, WithCode: true}

ListQuery is the FUNCTION LIST that Loaded sends: the nova_sprint library with its code. A reader that pipelines it with other reads passes the reply to FromList.

Functions

func FromList

func FromList(libs []redis.Library) (string, bool)

FromList is the nova_sprint library's code in a FUNCTION LIST reply, and false when the reply holds none.

func Load

func Load(ctx context.Context, client *redis.Client) error

Load installs the complete library atomically. REPLACE permits an updated binary to deploy its exact embedded version without a delete/load gap.

func LoadMissing

func LoadMissing(ctx context.Context, client *redis.Client) error

LoadMissing installs the embedded library only when the server holds no nova_sprint library, and never replaces one it holds. A verb that loads on the way to its FCALL (card push, drain and release, the reconciler's calls and expire duty) runs whatever binary its host has; with Load, an older binary REPLACEd the deployed library with its own and every function added since can vanish from the store, leaving newer callers without the functions they need. Upgrading the library is the deploy's job (`nova-sprint fn load`, which uses redisfn.Ensure). A caller whose ACL refuses FUNCTION LIST is not the deployer: it loads nothing and its FCALL answers for the store.

func Loaded

func Loaded(ctx context.Context, client *redis.Client) (string, bool, error)

Loaded returns the code of the nova_sprint library the server holds, and false when it holds none.

func Source

func Source() (string, error)

Source builds one library from all verb files. A verb is added by placing a Lua file in lua/; no central Lua registry needs to change. Each file is wrapped in its own do-block, so its top-level locals leave scope at its end: the main function holds len(Prelude locals) + the largest file's locals at once, not the sum over every file (Lua allows 200 active locals). A file shares nothing by bare local; what a later file needs goes through NS.

func Spec

func Spec() redisfn.Library

Spec is nova_sprint as pkg/redisfn describes a library: this package's files, glob and prelude, so a living tool loads and checks it with redisfn (nova-redis fn). Its Source is this package's Source, byte for byte, and so its digest is Sum's. Remedy is left for the tool to fill in its own words.

func Sum

func Sum(source string) string

Sum names one library version: the first 16 hex digits of the SHA-256 of its source. fn load prints it; fn check compares the loaded code's Sum with the embedded one.

Types

This section is empty.

Jump to

Keyboard shortcuts

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