Documentation ¶
Index ¶
- func CreateTestAccount(t *testing.T, store SimpleStore) api.Account
- func NonNullString(value string) sql.NullString
- func NullString() sql.NullString
- type JSONSerializer
- func (s JSONSerializer) DeserializeApplication(accountID int, formType string, formVersion string, serializedBody []byte) (api.Application, error)
- func (s JSONSerializer) DeserializeAttachment(accountID int, attachmentID int, metadata []byte, body []byte) (api.Attachment, error)
- func (s JSONSerializer) SerializeApplication(app api.Application) ([]byte, error)
- func (s JSONSerializer) SerializeAttachment(attachment api.Attachment) ([]byte, []byte, error)
- type SimpleStore
- func (s SimpleStore) Close() error
- func (s SimpleStore) CreateApplication(app api.Application) error
- func (s SimpleStore) CreateAttachment(attachment *api.Attachment) error
- func (s SimpleStore) CreateSession(accountID int, sessionKey string, sessionIndex sql.NullString, ...) error
- func (s SimpleStore) DeleteApplication(accountID int) error
- func (s SimpleStore) DeleteAttachment(accountID int, attachmentID int) error
- func (s SimpleStore) DeleteSession(sessionKey string) error
- func (s SimpleStore) ExtendAndFetchSessionAccount(sessionKey string, expirationDuration time.Duration) (api.Account, api.Session, error)
- func (s SimpleStore) FetchPossiblyExpiredSession(accountID int) (api.Session, error)
- func (s SimpleStore) ListAttachmentsMetadata(accountID int) ([]api.Attachment, error)
- func (s SimpleStore) LoadApplication(accountID int) (api.Application, error)
- func (s SimpleStore) LoadAttachment(accountID int, attachmentID int) (api.Attachment, error)
- func (s SimpleStore) SaveSection(section api.Section, accountID int) error
- func (s SimpleStore) UpdateApplication(app api.Application) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTestAccount ¶
func CreateTestAccount(t *testing.T, store SimpleStore) api.Account
CreateTestAccount is exported for now because there is no simplestore way of creating an account yet. Once the db stuff is ripped out I bet we can un-export this again
func NonNullString ¶
func NonNullString(value string) sql.NullString
NonNullString returns a valid sql.NullString
Types ¶
type JSONSerializer ¶
type JSONSerializer struct{}
JSONSerializer serializes an application to JSON for storage
func NewJSONSerializer ¶
func NewJSONSerializer() JSONSerializer
NewJSONSerializer returns a new JSON Serializer
func (JSONSerializer) DeserializeApplication ¶
func (s JSONSerializer) DeserializeApplication(accountID int, formType string, formVersion string, serializedBody []byte) (api.Application, error)
DeserializeApplication turns bytes into an Application
func (JSONSerializer) DeserializeAttachment ¶
func (s JSONSerializer) DeserializeAttachment(accountID int, attachmentID int, metadata []byte, body []byte) (api.Attachment, error)
DeserializeAttachment turns bytes into an Attachment
func (JSONSerializer) SerializeApplication ¶
func (s JSONSerializer) SerializeApplication(app api.Application) ([]byte, error)
SerializeApplication turns an Application into bytes for storage
func (JSONSerializer) SerializeAttachment ¶
func (s JSONSerializer) SerializeAttachment(attachment api.Attachment) ([]byte, []byte, error)
SerializeAttachment turns an Attachment into bytes
type SimpleStore ¶
type SimpleStore struct {
// contains filtered or unexported fields
}
SimpleStore saves JSON in the db for applications
func NewSimpleStore ¶
func NewSimpleStore(connectionString string, logger api.LogService, serializer api.Serializer) (SimpleStore, error)
NewSimpleStore returns a configured SimpleStore
func (SimpleStore) CreateApplication ¶
func (s SimpleStore) CreateApplication(app api.Application) error
CreateApplication saves an application in the db
func (SimpleStore) CreateAttachment ¶
func (s SimpleStore) CreateAttachment(attachment *api.Attachment) error
CreateAttachment saves an attachment in the db
func (SimpleStore) CreateSession ¶
func (s SimpleStore) CreateSession(accountID int, sessionKey string, sessionIndex sql.NullString, expirationDuration time.Duration) error
CreateSession creates a new session. It errors if a valid session already exists.
func (SimpleStore) DeleteApplication ¶
func (s SimpleStore) DeleteApplication(accountID int) error
DeleteApplication deletes an application from the database
func (SimpleStore) DeleteAttachment ¶
func (s SimpleStore) DeleteAttachment(accountID int, attachmentID int) error
DeleteAttachment deletes an attachment from the database
func (SimpleStore) DeleteSession ¶
func (s SimpleStore) DeleteSession(sessionKey string) error
DeleteSession removes a session record from the db
func (SimpleStore) ExtendAndFetchSessionAccount ¶
func (s SimpleStore) ExtendAndFetchSessionAccount(sessionKey string, expirationDuration time.Duration) (api.Account, api.Session, error)
ExtendAndFetchSessionAccount fetches an account and session data from the db On success it returns the account and the session On failure, it can return ErrValidSessionNotFound, ErrSessionExpired, or an unexpected error
func (SimpleStore) FetchPossiblyExpiredSession ¶
func (s SimpleStore) FetchPossiblyExpiredSession(accountID int) (api.Session, error)
FetchPossiblyExpiredSession returns a session row by account ID regardless of wether it is expired This is potentially dangerous, it is only intended to be used during the new login flow, never to check on a valid session for authentication purposes.
func (SimpleStore) ListAttachmentsMetadata ¶
func (s SimpleStore) ListAttachmentsMetadata(accountID int) ([]api.Attachment, error)
ListAttachmentsMetadata loads an attachment from the database NOTE, it does not fetch the body of the attachments, just the metadata
func (SimpleStore) LoadApplication ¶
func (s SimpleStore) LoadApplication(accountID int) (api.Application, error)
LoadApplication loads an application from the DB, it will return a NotFound error if it does not exist.
func (SimpleStore) LoadAttachment ¶
func (s SimpleStore) LoadAttachment(accountID int, attachmentID int) (api.Attachment, error)
LoadAttachment loads an attachment from the database
func (SimpleStore) SaveSection ¶
func (s SimpleStore) SaveSection(section api.Section, accountID int) error
SaveSection saves a single section in a given application
func (SimpleStore) UpdateApplication ¶
func (s SimpleStore) UpdateApplication(app api.Application) error
UpdateApplication updates an existing application