Documentation
¶
Index ¶
- type AccountFetcher
- type AllFetcher
- type Cache
- type CacheJSON
- type Category
- type CategoryFetcher
- type ComposedCache
- type Fetcher
- type MultiFetcher
- func (mf MultiFetcher) FetchAccount(ctx context.Context, accountID string) (account json.RawMessage, errs []error)
- func (mf MultiFetcher) FetchCategories(ctx context.Context, primaryAdServer, publisherId, iabCategory string) (string, error)
- func (mf MultiFetcher) FetchRequests(ctx context.Context, requestIDs []string, impIDs []string) (requestData map[string]json.RawMessage, impData map[string]json.RawMessage, ...)
- type NotFoundError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountFetcher ¶
type AllFetcher ¶
type AllFetcher interface { Fetcher AccountFetcher CategoryFetcher }
AllFetcher is an interface that encapsulates both the original Fetcher and the CategoryFetcher
func WithCache ¶
func WithCache(fetcher AllFetcher, cache Cache, metricsEngine metrics.MetricsEngine) AllFetcher
WithCache returns a Fetcher which uses the given Caches before delegating to the original. This can be called multiple times to compose Cache layers onto the backing Fetcher, though it is usually more desirable to first compose caches with Compose, ensuring propagation of updates and invalidations through all cache layers.
type Cache ¶
Cache is an intermediate layer which can be used to create more complex Fetchers by composition. Implementations must be safe for concurrent access by multiple goroutines. To add a Cache layer in front of a Fetcher, see WithCache()
type CacheJSON ¶
type CacheJSON interface { // Get works much like Fetcher.FetchRequests, with a few exceptions: // // 1. Any (actionable) errors should be logged by the implementation, rather than returned. // 2. The returned maps _may_ be written to. // 3. The returned maps must _not_ contain keys unless they were present in the argument ID list. // 4. Callers _should not_ assume that the returned maps contain key for every argument id. // The returned map will miss entries for keys which don't exist in the cache. // // Nil slices and empty strings are treated as "no ops". That is, a nil requestID will always produce a nil // "stored request data" in the response. Get(ctx context.Context, ids []string) (data map[string]json.RawMessage) // Invalidate will ensure that all values associated with the given IDs // are no longer returned by the cache until new values are saved via Update Invalidate(ctx context.Context, ids []string) // Save will add or overwrite the data in the cache at the given keys Save(ctx context.Context, data map[string]json.RawMessage) }
type CategoryFetcher ¶
type ComposedCache ¶
type ComposedCache []CacheJSON
ComposedCache creates an interface to treat a slice of caches as a single cache
func (ComposedCache) Get ¶
func (c ComposedCache) Get(ctx context.Context, ids []string) (data map[string]json.RawMessage)
Get will attempt to Get from the caches in the order in which they are in the slice, stopping as soon as a value is found (or when all caches have been exhausted)
func (ComposedCache) Invalidate ¶
func (c ComposedCache) Invalidate(ctx context.Context, ids []string)
Invalidate will propagate invalidations to all underlying caches
func (ComposedCache) Save ¶
func (c ComposedCache) Save(ctx context.Context, data map[string]json.RawMessage)
Save will propagate saves to all underlying caches
type Fetcher ¶
type Fetcher interface { // FetchRequests fetches the stored requests for the given IDs. // // The first return value will be the Stored Request data, or nil if it doesn't exist. // If requestID is an empty string, then this value will always be nil. // // The second return value will be a map from Stored Imp data. It will have a key for every ID // in the impIDs list, unless errors exist. // // The returned objects can only be read from. They may not be written to. FetchRequests(ctx context.Context, requestIDs []string, impIDs []string) (requestData map[string]json.RawMessage, impData map[string]json.RawMessage, errs []error) }
Fetcher knows how to fetch Stored Request data by id.
Implementations must be safe for concurrent access by multiple goroutines. Callers are expected to share a single instance as much as possible.
type MultiFetcher ¶
type MultiFetcher []AllFetcher
MultiFetcher is a Fetcher composed of multiple sub-Fetchers that are all polled for results.
func (MultiFetcher) FetchAccount ¶
func (mf MultiFetcher) FetchAccount(ctx context.Context, accountID string) (account json.RawMessage, errs []error)
func (MultiFetcher) FetchCategories ¶
func (MultiFetcher) FetchRequests ¶
func (mf MultiFetcher) FetchRequests(ctx context.Context, requestIDs []string, impIDs []string) (requestData map[string]json.RawMessage, impData map[string]json.RawMessage, errs []error)
FetchRequests implements the Fetcher interface for MultiFetcher
type NotFoundError ¶
NotFoundError is an error type to flag that an ID was not found by the Fetcher. This was added to support Multifetcher and any other case where we might expect that all IDs would not be found, and want to disentangle those errors from the others.
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string