Integrations
Section titled “Integrations”- Build hybrid search for your docs: Search Knotkit’s module docs by API name or by describing what you need.
- Rate-limit an Effect endpoint: Give each API client a request budget and return HTTP 429 with a retry time.
Queues and ordering
Section titled “Queues and ordering”- Keep the k largest values of a stream: Hold a min heap of size
kand replace its root whenever a larger value arrives. - Change the priority of queued work: An indexed priority queue finds a queued item by its value and moves it in place.
- Pick the k items that cover the most: Lazy greedy keeps every candidate in a max heap keyed by its last known gain and re-evaluates only the top.
- Read the first n items of several sorted lists: Merge sorted inputs lazily, and stop as soon as you have enough.
- Compute a rolling average over the last n values: A bounded deque returns the value a push evicts, so the running sum subtracts exactly what left the window.
Sets and caches
Section titled “Sets and caches”- Deduplicate records by numeric id: A Roaring bitset records which ids you have seen in about two bytes per id, or one bit per possible id once ids are dense.
- Cap a cache by entry count: A SIEVE cache keeps at most
capacityentries and returns what it evicted from everyset. - Limit each client to a request rate: A keyed table builds one rate-limit meter per client, spends and refuses weight on that client alone, and forgets a client only once its meter would decide like a fresh one.
- Find which items are connected: A disjoint set merges groups as links arrive and answers whether two items are in the same group.
Randomness and statistics
Section titled “Randomness and statistics”- Shuffle reproducibly from a seed: Pass a seeded random source to
shuffled, and the same seed gives the same order on every machine. - Sample a stream of unknown length: A reservoir sampler keeps a uniform sample of fixed size, however many items pass through.
- Test whether two samples differ: The Mann–Whitney U test compares two independent samples without assuming they are normal.
Saving and loading
Section titled “Saving and loading”- Save a structure and load it back: Serialization lives in a
/wiresubpath. It writes versioned bytes and restores the same layout.
Larger examples
Section titled “Larger examples”See how the same modules work together on larger workloads, from road routing to near-duplicate detection. Browse all examples.