editsession

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package editsession reads/deletes the shared, session-backed volume edit state that catalog-web writes to Redis (REDIS_DB=2 on catalog-api's own Redis instance - see docs/frontend-conventions.md's edit-session schema in sweetrpg/platform). catalog-api reads a session at finalize time and deletes it once finalize completes; the one exception to "catalog-api never creates a session" is pull-back (task 5.4), which recreates a pending proposal's diff as a fresh session so the submitter can resume editing it.

Index

Constants

View Source
const KeyPrefix = "edit-session"

KeyPrefix is the Redis key namespace for edit sessions: "edit-session:<userId>:<recordType>".

Variables

This section is empty.

Functions

func Key

func Key(userID, recordType string) string

Key returns the Redis key for a user's in-flight session on a given record type.

Types

type Session

type Session struct {
	RecordID           string         `json:"recordId"`
	Fields             map[string]any `json:"fields"`
	StagedCoverAssetId string         `json:"stagedCoverAssetId,omitempty"`
	SampleAssetIds     []string       `json:"sampleAssetIds,omitempty"`
	CreatedAt          time.Time      `json:"createdAt"`
	UpdatedAt          time.Time      `json:"updatedAt"`
}

Session mirrors the JSON schema catalog-web writes.

type Store

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

Store reads/deletes edit sessions against a Redis pool already selecting REDIS_DB=2.

func NewStore

func NewStore(pool *redis.Pool) *Store

NewStore wraps pool - the caller is responsible for the pool already dialing REDIS_DB=2.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, userID, recordType string) error

Delete removes a user's in-flight session for recordType. A missing session is not an error.

func (*Store) Get

func (s *Store) Get(ctx context.Context, userID, recordType string) (*Session, error)

Get fetches a user's in-flight session for recordType, or nil if none exists.

func (*Store) Set

func (s *Store) Set(ctx context.Context, userID, recordType string, session Session) error

Set writes userID's session for recordType, overwriting any existing one. Used only by pull-back (task 5.4) - every other session write comes from catalog-web directly.

Jump to

Keyboard shortcuts

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