Documentation ¶
Index ¶
- func WithUserRecord(ctx context.Context, u User) context.Context
- type Amount
- type MockProfileCache
- func (m MockProfileCache) GetTrades(_ context.Context, _ string) ([]TradeRecord, bool, error)
- func (m MockProfileCache) GetValuation(_ context.Context, _ string, _ time.Time) ([]ValuationHistory, bool, error)
- func (m MockProfileCache) InvalidateTrades(_ context.Context, _ string) error
- func (m MockProfileCache) SaveTrades(_ context.Context, _ string, v []TradeRecord) error
- func (m MockProfileCache) SaveValuation(_ context.Context, _ string, _ time.Time, v []ValuationHistory) error
- type Portfolio
- type ProfileCache
- type TradeRecord
- type User
- type UserDB
- func (u *UserDB) Create(ctx context.Context, au auth.AuthenticatedUser) error
- func (u *UserDB) EnsureAccountExists(ctx context.Context, au auth.AuthenticatedUser) (User, error)
- func (u *UserDB) EnsureAccountExistsInterceptor() grpc_auth.AuthFunc
- func (u *UserDB) Get(ctx context.Context, userID string) (User, bool, error)
- func (u *UserDB) GetAll(ctx context.Context) ([]User, error)
- func (u *UserDB) RotateTradeHistory(ctx context.Context, uid string, maxHist int) error
- func (u *UserDB) RotateUserValuationHistory(ctx context.Context, uid string, deleteBefore time.Time) error
- func (u *UserDB) SetUserValuationHistory(ctx context.Context, uid string, v ValuationHistory) error
- func (u *UserDB) Trade(ctx context.Context, uid string, ticker string, action grpcoin.TradeAction, ...) (Portfolio, error)
- func (u *UserDB) UserTrades(ctx context.Context, uid string) ([]TradeRecord, error)
- func (u *UserDB) UserValuationHistory(ctx context.Context, uid string) ([]ValuationHistory, error)
- type UserDBCache
- func (u UserDBCache) GetTrades(ctx context.Context, uid string) ([]TradeRecord, bool, error)
- func (u UserDBCache) GetValuation(ctx context.Context, uid string, now time.Time) ([]ValuationHistory, bool, error)
- func (u UserDBCache) InvalidateTrades(ctx context.Context, uid string) error
- func (u UserDBCache) SaveTrades(ctx context.Context, uid string, v []TradeRecord) error
- func (u UserDBCache) SaveValuation(ctx context.Context, uid string, now time.Time, v []ValuationHistory) error
- type ValuationHistory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Amount ¶
func (Amount) IsNegative ¶
type MockProfileCache ¶
type MockProfileCache struct{}
func (MockProfileCache) GetTrades ¶
func (m MockProfileCache) GetTrades(_ context.Context, _ string) ([]TradeRecord, bool, error)
func (MockProfileCache) GetValuation ¶
func (m MockProfileCache) GetValuation(_ context.Context, _ string, _ time.Time) ([]ValuationHistory, bool, error)
func (MockProfileCache) InvalidateTrades ¶
func (m MockProfileCache) InvalidateTrades(_ context.Context, _ string) error
func (MockProfileCache) SaveTrades ¶
func (m MockProfileCache) SaveTrades(_ context.Context, _ string, v []TradeRecord) error
func (MockProfileCache) SaveValuation ¶
func (m MockProfileCache) SaveValuation(_ context.Context, _ string, _ time.Time, v []ValuationHistory) error
type ProfileCache ¶
type ProfileCache interface { GetTrades(ctx context.Context, uid string) ([]TradeRecord, bool, error) SaveTrades(ctx context.Context, uid string, v []TradeRecord) error InvalidateTrades(ctx context.Context, uid string) error GetValuation(ctx context.Context, uid string, now time.Time) ([]ValuationHistory, bool, error) SaveValuation(ctx context.Context, uid string, now time.Time, v []ValuationHistory) error }
type TradeRecord ¶
type TradeRecord struct { Date time.Time `firestore:"date"` Ticker string `firestore:"ticker"` Action grpcoin.TradeAction `firestore:"action"` Size Amount `firestore:"size"` Price Amount `firestore:"price"` }
TradeRecord represents a trade user has made in the past.
type User ¶
type UserDB ¶
type UserDB struct { DB *firestore.Client Cache ProfileCache TradeCounter *tradecounters.TradeCounter T trace.Tracer }
func (*UserDB) EnsureAccountExists ¶
func (*UserDB) EnsureAccountExistsInterceptor ¶
EnsureAccountExistsInterceptor creates an account for the authenticated client (or retrieves it) and augments the ctx with the user's db record.
func (*UserDB) RotateTradeHistory ¶
func (*UserDB) RotateUserValuationHistory ¶
func (*UserDB) SetUserValuationHistory ¶
func (*UserDB) UserTrades ¶
func (*UserDB) UserValuationHistory ¶
type UserDBCache ¶
type UserDBCache struct {
R *redis.Client
}
func (UserDBCache) GetTrades ¶
func (u UserDBCache) GetTrades(ctx context.Context, uid string) ([]TradeRecord, bool, error)
func (UserDBCache) GetValuation ¶
func (u UserDBCache) GetValuation(ctx context.Context, uid string, now time.Time) ([]ValuationHistory, bool, error)
func (UserDBCache) InvalidateTrades ¶
func (u UserDBCache) InvalidateTrades(ctx context.Context, uid string) error
func (UserDBCache) SaveTrades ¶
func (u UserDBCache) SaveTrades(ctx context.Context, uid string, v []TradeRecord) error
func (UserDBCache) SaveValuation ¶
func (u UserDBCache) SaveValuation(ctx context.Context, uid string, now time.Time, v []ValuationHistory) error
type ValuationHistory ¶
ValuationHistory represents user's portfolio value at a particular time.
Click to show internal directories.
Click to hide internal directories.