Help us shape the future of Go! Take the 2026 Go Developer Survey

memory

package
v0.3.6 Latest Latest
Warning

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

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

Documentation

Overview

Package memory provides an in-process ReplayBuffer backend for single-pod deployments (dev / replica=1), where a reconnect lands on the same pod so cross-pod sharing is unnecessary. It satisfies the same core/interfaces.ReplayBuffer contract as the Redis backend, so selecting it is a config change (replay backend = memory), never a logic edit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer is an in-process ReplayBuffer: a mutex-guarded map of key → an ordered, bounded, TTL'd list of retained messages.

func New

func New(maxSize int, ttl time.Duration) *Buffer

New returns an in-process ReplayBuffer bounded to maxSize entries per key with the given TTL.

func (*Buffer) Append

func (b *Buffer) Append(_ context.Context, key, msgID string, payload []byte) error

Append records payload under key, evicting the oldest past maxSize and refreshing the TTL.

func (*Buffer) Delete

func (b *Buffer) Delete(_ context.Context, key string) error

Delete removes the key's buffer entirely.

func (*Buffer) Prune

func (b *Buffer) Prune(_ context.Context, key, upToMsgID string) error

Prune drops entries up to and including upToMsgID, recording it as the low-water mark.

func (*Buffer) ReplayAfter

func (b *Buffer) ReplayAfter(
	_ context.Context,
	key, afterMsgID string,
) ([]interfaces.BufferedMessage, bool, error)

ReplayAfter returns the retained tail strictly after afterMsgID; see the interface doc for the complete-flag semantics.

Jump to

Keyboard shortcuts

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