Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Engine ¶
type Engine interface { // SaveSession permanently saves the given new session SaveSession(newSession *wwr.Session) error // FindSession searches for a session identified by `key` FindSession(key string) (wwr.SessionLookupResult, error) // CloseSession closes the session identified by `key` CloseSession(key string) error // AuthenticateUser returns the account of the user identified by `username` AuthenticateUser(username string) ( profile *api.User, password string, err error, ) // CreateUser permanently saves the new account. // Returns an error if the identifier or username are already reserved CreateUser(newAccount *api.User, passwordHash string) error // GetUser retrieves the user profile by identifier GetUser(ident api.Identifier) (*api.User, error) // GetPosts retrieves the posts identified by `idents` // returning them in the same order as `idents` GetPosts(idents []api.Identifier) ([]*api.Post, error) // GetPostReactions retrieves the post reactions identified by `idents` // returning them in the same order as `idents` GetPostReactions(idents []api.Identifier) ([]*api.PostReaction, error) // GetReactionsOfPost retrieves all reactions of a certain post GetReactionsOfPost(postIdent api.Identifier) ([]*api.PostReaction, error) // GetPostsAfter retrieves n posts (n = `limit`) after the post // identified by `after`. // If `after` is nil then the latest post will be applied GetPostsAfter( after *api.Identifier, limit uint32, ) ([]*api.Post, error) // CreatePost appends a new post to the history CreatePost(newPost *api.Post) error // EditPost edits the contents of the post identified by `ident` // setting the contents to `newContents` updating last-edit time to // editTime EditPost( ident api.Identifier, editTime time.Time, newContents string, ) error // RemovePost permanently removes the post identified by `ident` // from the history RemovePost(ident api.Identifier) error // RemovePostReaction permanently removes the post reaction // identified by `ident` from the history RemovePostReaction(ident api.Identifier) error // CreatePostReaction posts a reaction to the post identified by `ident` CreatePostReaction( postIdent api.Identifier, reaction *api.PostReaction, ) error }
Engine defines the service engine interface
type EngineError ¶
type EngineError struct {
Code ErrorCode
}
EngineError represents an implementation of the standard Go error interface. It represents an error returned by the engine implementation
func ToEngineError ¶
func ToEngineError(err error) *EngineError
ToEngineError returns an engine error if the given error interface houses one, otherwise returns nil
func (EngineError) Error ¶
func (err EngineError) Error() string
Error implements the standard Go error interface
type ErrorCode ¶
type ErrorCode int
ErrorCode represents an engine error code
const ( // ErrInternal indicates that an internal error occurred ErrInternal ErrorCode // ErrInvalidRequest indicates that the received request is invalid // and cannot be processed ErrInvalidRequest // to execute any given operation ErrUnauthorized // ErrWrongCredentials indicates that the provided login credentials // are incorrect ErrWrongCredentials // ErrUsernameReserved indicates that a username is already reserved // by another user's account ErrUsernameReserved // ErrPostNotFound indicates that the targeted post doesn't exist ErrPostNotFound // ErrPostReactionNotFound indicates that the targeted post reaction // doesn't exist ErrPostReactionNotFound // ErrPostAlreadyExists indicates that a post // with a similar identifier already exists ErrPostAlreadyExists // ErrUserNotFound indicates that the targeted user account doesn't exist ErrUserNotFound )
Click to show internal directories.
Click to hide internal directories.