Documentation
¶
Overview ¶
Package botsfwstoredalgo is the DALgo implementation of botsfwstore.StateStore.
It deliberately retains the historical botPlatforms/bots/botUsers/botChats key layout, so moving to this adapter requires no data migration.
Index ¶
- func CreatePlatformUserRecord(ctx context.Context, tx dal.ReadwriteTransaction, platformID, userID string, ...) error
- func NewBotChatKey[PlatformID ~string](platformID PlatformID, botID, chatID string) *dalrecord.Key
- func NewBotKey[PlatformID ~string](platformID PlatformID, botID string) *dalrecord.Key
- func NewPlatformKey[PlatformID ~string](platformID PlatformID) *dalrecord.Key
- func NewPlatformUserKey[PlatformID ~string](platformID PlatformID, userID string) *dalrecord.Key
- type AppUserStore
- type BotUser
- type DBProvider
- type PlatformUserRecord
- type StateStore
- func (s *StateStore) AppUser(ctx context.Context, botID, appUserID string) (result botsfwstore.AppUser, err error)
- func (s *StateStore) EnsureLinked(ctx context.Context, request botsfwstore.LinkRequest) (linked botsfwstore.LinkedIdentity, err error)
- func (s *StateStore) PlatformUser(ctx context.Context, identity botsfwstore.Identity, ...) (result botsfwstore.PlatformUser, err error)
- func (s *StateStore) SaveChat(ctx context.Context, identity botsfwstore.Identity, ...) error
- func (s *StateStore) SetPlatformUserAccessGranted(ctx context.Context, identity botsfwstore.Identity, ...) (result botsfwstore.PlatformUser, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreatePlatformUserRecord ¶
func CreatePlatformUserRecord(ctx context.Context, tx dal.ReadwriteTransaction, platformID, userID string, data botsfwmodels.PlatformUserData) error
CreatePlatformUserRecord inserts a platform user in the historical schema.
func NewBotChatKey ¶
NewBotChatKey creates the historical bot-chat key.
func NewPlatformKey ¶
NewPlatformKey creates the historical top-level platform key.
Types ¶
type AppUserStore ¶
type AppUserStore interface {
PrepareAppUser(ctx context.Context, identity botsfwstore.Identity) (botsfwstore.AppUser, error)
EnsureAppUser(ctx context.Context, tx dal.ReadwriteTransaction, identity botsfwstore.Identity, prepared botsfwstore.AppUser) (botsfwstore.AppUser, error)
AppUser(ctx context.Context, tx dal.ReadSession, botID, appUserID string) (botsfwstore.AppUser, error)
}
AppUserStore is the application-owned half of DALgo identity persistence. PrepareAppUser runs before the adapter transaction and may idempotently provision an external identity such as Firebase Auth. It must not persist the application user in DALgo. EnsureAppUser then persists that prepared user using only the supplied retryable transaction. This lets the adapter commit the application user, platform link, and chat atomically without repeating external side effects.
type BotUser ¶
type BotUser = PlatformUserRecord
BotUser is a deprecated schema-level alias retained only to make application DALgo login tests readable during migration. New code should use PlatformUserRecord; public facades should return botsfwstore.PlatformUser.
type DBProvider ¶
DBProvider returns the DALgo database for a request context. It supports hosts that select a database from tenant or request metadata.
type PlatformUserRecord ¶
type PlatformUserRecord = dalrecord.DataWithID[string, botsfwmodels.PlatformUserData]
PlatformUserRecord is the DALgo representation of a platform user. It is exported for application-owned identity flows that intentionally operate on the historical schema without importing DALgo into bots-fw itself.
func GetPlatformUser ¶
func GetPlatformUser(ctx context.Context, reader dal.ReadSession, platformID, userID string, data botsfwmodels.PlatformUserData) (PlatformUserRecord, error)
GetPlatformUser loads a platform user from the historical schema.
type StateStore ¶
type StateStore struct {
// contains filtered or unexported fields
}
StateStore is the default DALgo-backed implementation of the framework store.
func NewStateStore ¶
func NewStateStore(db dal.DB, appUsers AppUserStore) *StateStore
NewStateStore creates a DALgo state-store adapter.
func NewStateStoreWithProvider ¶
func NewStateStoreWithProvider(getDB DBProvider, appUsers AppUserStore) *StateStore
NewStateStoreWithProvider creates a DALgo state-store adapter whose database is resolved for each operation.
func (*StateStore) AppUser ¶
func (s *StateStore) AppUser(ctx context.Context, botID, appUserID string) (result botsfwstore.AppUser, err error)
func (*StateStore) EnsureLinked ¶
func (s *StateStore) EnsureLinked(ctx context.Context, request botsfwstore.LinkRequest) (linked botsfwstore.LinkedIdentity, err error)
func (*StateStore) PlatformUser ¶
func (s *StateStore) PlatformUser(ctx context.Context, identity botsfwstore.Identity, newData func() botsfwmodels.PlatformUserData) (result botsfwstore.PlatformUser, err error)
func (*StateStore) SaveChat ¶
func (s *StateStore) SaveChat(ctx context.Context, identity botsfwstore.Identity, data botsfwmodels.BotChatData) error
func (*StateStore) SetPlatformUserAccessGranted ¶
func (s *StateStore) SetPlatformUserAccessGranted(ctx context.Context, identity botsfwstore.Identity, newData func() botsfwmodels.PlatformUserData, value bool) (result botsfwstore.PlatformUser, err error)