Documentation ¶
Index ¶
- func CloseSession(db HasSession)
- func EnsureStats(ctx context.Context, db HasSession) error
- func EnsureUsers(ctx context.Context, db HasSession) error
- func OpenSession(db HasSession, hosts []string) error
- type DB
- func (db *DB) Disconnect()
- func (db *DB) GetAllUserAccounts(ctx context.Context) <-chan *UserAccountWithError
- func (db *DB) GetSession() *gocql.Session
- func (db *DB) Init() error
- func (db *DB) SetSession(session *gocql.Session) error
- func (db *DB) UpdateDailyRecord(ctx context.Context, portfolio *PortfolioValue) error
- type DailyPortfolioStats
- type HasSession
- type PortfolioValue
- type UserAccount
- type UserAccountWithError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureStats ¶
func EnsureStats(ctx context.Context, db HasSession) error
EnsureStats creates all stats related tables if they are missing
func EnsureUsers ¶
func EnsureUsers(ctx context.Context, db HasSession) error
EnsureUsers creates all user related tables if they are missing
func OpenSession ¶
func OpenSession(db HasSession, hosts []string) error
OpenSession creates a news db session and sets to HasSession interface
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB stores the session and model methods are defined on it
func (*DB) GetAllUserAccounts ¶
func (db *DB) GetAllUserAccounts(ctx context.Context) <-chan *UserAccountWithError
GetAllUserAccounts returns all accounts for all users with a channel
func (*DB) GetSession ¶
GetSession return session to satisfy HasSession interface
func (*DB) SetSession ¶
SetSession sets the session to satisfy HasSession interface
func (*DB) UpdateDailyRecord ¶
func (db *DB) UpdateDailyRecord(ctx context.Context, portfolio *PortfolioValue) error
UpdateDailyRecord updates daily AVG, MAX, MIN records for portfolios
type DailyPortfolioStats ¶
type DailyPortfolioStats struct { UserID gocql.UUID AccountType string Date string Avg float64 Last float64 Max float64 Min float64 N int }
DailyPortfolioStats contains main portfolio stats for a single day
type HasSession ¶
HasSession can store and return gocql session
type PortfolioValue ¶
type PortfolioValue struct { UserID gocql.UUID AccountType string Date string Invested float64 Yield float64 }
PortfolioValue contains total portfolio value with separate Invested and Yield fields
type UserAccount ¶
UserAccount represents one of user's stocks account
type UserAccountWithError ¶
type UserAccountWithError struct { Account *UserAccount Error error }
UserAccountWithError contains UserAccount bundled with an error