Documentation ¶
Index ¶
- Constants
- type Medium
- type MediumFile
- func (m *MediumFile) AddSource(ctx context.Context, userID string, source string) error
- func (m *MediumFile) DeleteSource(ctx context.Context, userID string, sourceID string) error
- func (m *MediumFile) GetAllSourceData(ctx context.Context, userID string, page int) ([]Medium, error)
- func (m *MediumFile) GetSources(ctx context.Context, userID string, page int) ([]Source, error)
- func (m *MediumFile) Start(ctx context.Context) error
- func (m *MediumFile) UpdateSource(ctx context.Context, userID string, source Medium) error
- type Source
- type UserFile
Constants ¶
const ( ErrCannotOpenMediumFile = err.Const("cannot open medium file") ErrCannotReadMediumFile = err.Const("cannot read medium file") ErrCannotUnmarshallMediumFile = err.Const("cannot unmarshall medium file") ErrCannotFindMedium = err.Const("cannot find medium") )
const ( ErrCannotOpenUserFile = err.Const("cannot open user file") ErrCannotReadUserFile = err.Const("cannot read user file") ErrCannotUnmarshallUserFile = err.Const("cannot unmarshall user file") ErrUserAlreadyExists = err.Const("user already exists") ErrUserNotFound = err.Const("user not found") ErrMediumSourceAlreadyExists = err.Const("medium source already exits") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MediumFile ¶
type MediumFile struct {
// contains filtered or unexported fields
}
MediumFile is the type that will store the medium information in a file on disk
func NewMediumFile ¶
func NewMediumFile(ctx context.Context, filename string, ticker time.Duration, elemsInPage int) (*MediumFile, error)
NewMediumFile will create a new instance of MediumFile This is not thread safe
func (*MediumFile) DeleteSource ¶
DeleteSource will delete a source given the userID and sourceID
func (*MediumFile) GetAllSourceData ¶
func (m *MediumFile) GetAllSourceData(ctx context.Context, userID string, page int) ([]Medium, error)
GetAllSourceData returns the sources on the selected page
func (*MediumFile) GetSources ¶
GetSources returns the sources on the selected page
func (*MediumFile) Start ¶
func (m *MediumFile) Start(ctx context.Context) error
Start will start the background job that will periodically save what's in memory
func (*MediumFile) UpdateSource ¶
UpdateSource will update the given source for the user
type UserFile ¶
type UserFile struct {
// contains filtered or unexported fields
}
UserFile is the type that will store the user information in a file on disk
func NewUserFile ¶
NewUserFile will create a new instance of UserFile This is not thread safe
func (*UserFile) CreateNewUser ¶
CreateNewUser will create a new user that is needed to add medium sources. It returns the uuid of the new user.
func (*UserFile) GetUser ¶
GetUser will retrieve the user details. It will return the uuid of the user.