initial commit

This commit is contained in:
abelith committed 2026-10-02 00:48:55 +03:00
commit bec2cfd017
18 files changed
+781

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
package memory
import (
"context"
"github.com/abelith/gomax/state"
"sync"
)
type FSMStorage struct {
m sync.Map
}
func NewMemoryFSMStorage() *FSMStorage {
return &FSMStorage{}
}
func (f *FSMStorage) Get(_ context.Context, userID int) (*state.Snapshot, error) {
st, ok := f.m.Load(userID)
if !ok {
return nil, state.ErrStateNotFound
}
return st.(*state.Snapshot), nil
}
func (f *FSMStorage) Put(_ context.Context, snapshot *state.Snapshot) error {
f.m.Store(snapshot.ID, snapshot)
return nil
}
func (f *FSMStorage) Delete(_ context.Context, snapshot *state.Snapshot) error {
f.m.Delete(snapshot.ID)
return nil
}