Documentation ¶
Index ¶
- type Repository
- type RepositoryImpl
- func (r *RepositoryImpl) AddFollowRecord(ctx context.Context, follower string, target string) error
- func (r *RepositoryImpl) AddPost(ctx context.Context, username string, post []byte) error
- func (r *RepositoryImpl) AddUser(ctx context.Context, user []byte) error
- func (r *RepositoryImpl) AssertCredentials(ctx context.Context, username, password []byte) error
- func (r *RepositoryImpl) DeleteFollowRecord(ctx context.Context, follower string, target string) error
- func (r *RepositoryImpl) GetFollowers(ctx context.Context, username string) (models.UserSlice, error)
- func (r *RepositoryImpl) GetFollowing(ctx context.Context, username string) (models.UserSlice, error)
- func (r *RepositoryImpl) GetTargetsPosts(ctx context.Context, username string) (models.PostSlice, error)
- func (r *RepositoryImpl) GetUserByUsername(ctx context.Context, username string) (*models.User, error)
- type Settings
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository interface { AssertCredentials(ctx context.Context, username, password []byte) error AddUser(ctx context.Context, user []byte) error GetUserByUsername(ctx context.Context, username string) (*models.User, error) AddFollowRecord(ctx context.Context, follower string, target string) error DeleteFollowRecord(ctx context.Context, follower string, target string) error GetFollowers(ctx context.Context, username string) (models.UserSlice, error) GetFollowing(ctx context.Context, username string) (models.UserSlice, error) AddPost(ctx context.Context, username string, post []byte) error GetTargetsPosts(ctx context.Context, username string) (models.PostSlice, error) }
Repository wraps the storage and provides domain specific functions to interact with the storage
func NewRepository ¶
func NewRepository(storage Storage) Repository
NewRepository returns new repository for a given storage
type RepositoryImpl ¶ added in v0.0.2
type RepositoryImpl struct {
// contains filtered or unexported fields
}
RepositoryImpl implements Repository in order to interact with storage
func (*RepositoryImpl) AddFollowRecord ¶ added in v0.0.2
AddFollowRecord adds a follow relation between two users of type `follower follows target`
func (*RepositoryImpl) AddUser ¶ added in v0.0.2
func (r *RepositoryImpl) AddUser(ctx context.Context, user []byte) error
AddUser adds user given as byte slice into the database
func (*RepositoryImpl) AssertCredentials ¶ added in v0.0.2
func (r *RepositoryImpl) AssertCredentials(ctx context.Context, username, password []byte) error
AssertCredentials checks if given username and password are the same as persisted into the database
func (*RepositoryImpl) DeleteFollowRecord ¶ added in v0.0.2
func (r *RepositoryImpl) DeleteFollowRecord(ctx context.Context, follower string, target string) error
DeleteFollowRecord deletes a follow relation between two users
func (*RepositoryImpl) GetFollowers ¶ added in v0.0.2
func (r *RepositoryImpl) GetFollowers(ctx context.Context, username string) (models.UserSlice, error)
GetFollowers returns all the followers of a given user
func (*RepositoryImpl) GetFollowing ¶ added in v0.0.2
func (r *RepositoryImpl) GetFollowing(ctx context.Context, username string) (models.UserSlice, error)
GetFollowing returns all the users who follow a given user
func (*RepositoryImpl) GetTargetsPosts ¶ added in v0.0.2
func (r *RepositoryImpl) GetTargetsPosts(ctx context.Context, username string) (models.PostSlice, error)
GetTargetsPosts returns all the posts which a given user can see
func (*RepositoryImpl) GetUserByUsername ¶ added in v0.0.2
func (r *RepositoryImpl) GetUserByUsername(ctx context.Context, username string) (*models.User, error)
GetUserByUsername returns user entity for a given user identified by username
type Settings ¶
type Settings struct { Type string `mapstructure:"type" description:"Type of the storage"` URI string `mapstructure:"uri" description:"URI of the storage"` SkipSSLValidation bool `mapstructure:"skip_ssl_validation" description:"whether to skip ssl verification when connecting to the storage"` }
Settings holds all storage configuration settings
func DefaultSettings ¶
func DefaultSettings() *Settings
DefaultSettings returns default settings for the storage