Documentation
¶
Overview ¶
Package redis provides Redis-backed conversation storage. Use when using remote workers so the worker process can access conversation data. Agent and worker use the same Redis config; conversation ID is passed at runtime via Run and the agent run input.
Index ¶
- type Option
- type RedisConversation
- func (c *RedisConversation) AddMessage(ctx context.Context, id string, msg interfaces.Message) error
- func (c *RedisConversation) Clear(ctx context.Context, id string) error
- func (c *RedisConversation) Close() error
- func (c *RedisConversation) IsDistributed() bool
- func (c *RedisConversation) ListMessages(ctx context.Context, id string, opts ...interfaces.ListMessagesOption) ([]interfaces.Message, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*RedisConversation)
Option configures RedisConversation.
func WithClient ¶
WithClient sets the Redis client. When set, addr/password/db are ignored. Close() will NOT close the client.
func WithKeyPrefix ¶
WithKeyPrefix sets the Redis key prefix.
func WithMaxSize ¶
WithMaxSize sets the maximum number of messages to store. Oldest are trimmed when exceeded.
type RedisConversation ¶
type RedisConversation struct {
// contains filtered or unexported fields
}
func NewRedisConversation ¶
func NewRedisConversation(opts ...Option) (*RedisConversation, error)
NewRedisConversation creates a Redis-backed conversation from options. Use WithClient to provide your own client; otherwise addr is required to create a client. Call Close() when done if you did not use WithClient.
func (*RedisConversation) AddMessage ¶
func (c *RedisConversation) AddMessage(ctx context.Context, id string, msg interfaces.Message) error
func (*RedisConversation) Clear ¶
func (c *RedisConversation) Clear(ctx context.Context, id string) error
func (*RedisConversation) Close ¶
func (c *RedisConversation) Close() error
Close releases the Redis connection only when we own it (not using WithClient).
func (*RedisConversation) IsDistributed ¶
func (c *RedisConversation) IsDistributed() bool
func (*RedisConversation) ListMessages ¶
func (c *RedisConversation) ListMessages(ctx context.Context, id string, opts ...interfaces.ListMessagesOption) ([]interfaces.Message, error)