Documentation ¶
Index ¶
- Variables
- type Consumer
- type Counts
- type CountsMap
- type List
- type Map
- type Producer
- type QueryOptions
- type Reaction
- type Service
- type ServiceMiddleware
- func CacheServiceMiddleware(countsCache cache.CountService) ServiceMiddleware
- func InstrumentServiceMiddleware(component, store string, errCount kitmetrics.Counter, ...) ServiceMiddleware
- func LogServiceMiddleware(logger log.Logger, store string) ServiceMiddleware
- func SourcingServiceMiddleware(producer Producer) ServiceMiddleware
- type Source
- type SourceMiddleware
- type StateChange
- type Type
Constants ¶
This section is empty.
Variables ¶
var TypeToIdentifier = map[Type]string{ TypeLike: "like", TypeLove: "love", TypeHaha: "haha", TypeWow: "wow", TypeSad: "sad", TypeAngry: "angry", }
TypeToIdentifier is the lookup of a reaction type to human readable idenitfier.
Functions ¶
This section is empty.
Types ¶
type Consumer ¶
type Consumer interface {
Consume() (*StateChange, error)
}
Consumer observes state changes.
type List ¶
type List []*Reaction
List is a collection of Reaction.
type QueryOptions ¶
type QueryOptions struct { Before time.Time `json:"-"` Deleted *bool `json:"deleted,omitempty"` IDs []uint64 `json:"-"` Limit int `json:"-"` ObjectIDs []uint64 `json:"object_ids"` OwnerIDs []uint64 `json:"owner_ids"` Types []Type `json:"types"` }
QueryOptions to narrow-down queries.
type Reaction ¶
type Reaction struct { Deleted bool ID uint64 ObjectID uint64 OwnerID uint64 Type Type CreatedAt time.Time UpdatedAt time.Time }
Reaction is the building block to express interactions on Objects/Posts.
func (*Reaction) MatchOpts ¶
func (r *Reaction) MatchOpts(opts *QueryOptions) bool
MatchOpts indicates if the Reaction matches the given QueryOptions.
type Service ¶
type Service interface { service.Lifecycle Count(namespace string, opts QueryOptions) (uint, error) CountMulti(namespace string, opts QueryOptions) (CountsMap, error) Put(namespace string, reaction *Reaction) (*Reaction, error) Query(namespace string, opts QueryOptions) (List, error) }
Service for Reaction interactions.
func MemService ¶
func MemService() Service
MemService returns a memory based Service implementation.
func PostgresService ¶
PostgresService returns a Postgres based Service inplementation.
type ServiceMiddleware ¶
ServiceMiddleware is a chainable behaviour modifier for Service.
func CacheServiceMiddleware ¶
func CacheServiceMiddleware(countsCache cache.CountService) ServiceMiddleware
CacheServiceMiddleware adds caching capabilities to the Service by using read-through and write-through methods to store resutls of heavy computation with sensible TTLs.
func InstrumentServiceMiddleware ¶
func InstrumentServiceMiddleware( component, store string, errCount kitmetrics.Counter, opCount kitmetrics.Counter, opLatency *prometheus.HistogramVec, ) ServiceMiddleware
InstrumentServiceMiddleware observes key apsects of Service operations and exposes Prometheus metrics.
func LogServiceMiddleware ¶
func LogServiceMiddleware(logger log.Logger, store string) ServiceMiddleware
LogServiceMiddleware given a logger wraps the next Service with logging capabilities.
func SourcingServiceMiddleware ¶
func SourcingServiceMiddleware(producer Producer) ServiceMiddleware
type SourceMiddleware ¶
SourceMiddleware is a chainable behaviour modifier for Source.
func InstrumentSourceMiddleware ¶
func InstrumentSourceMiddleware( component, store string, errCount kitmetrics.Counter, opCount kitmetrics.Counter, opLatency *prometheus.HistogramVec, queueLatency *prometheus.HistogramVec, ) SourceMiddleware
InstrumentSourceMiddleware observes key apsects of Source operations and exposes Prometheus metrics.
func LogSourceMiddleware ¶
func LogSourceMiddleware(store string, logger log.Logger) SourceMiddleware
LogSourceMiddleware given a Logger wraps the next Source with logging capabilities.