| Index: service/memcache/context.go
|
| diff --git a/service/memcache/context.go b/service/memcache/context.go
|
| index 2287dd56f1cbe0abe3723151131a5172b17f6ef2..851b299adf5a436ba693b18c825714eaca339392 100644
|
| --- a/service/memcache/context.go
|
| +++ b/service/memcache/context.go
|
| @@ -15,26 +15,26 @@ var (
|
| memcacheFilterKey key = 1
|
| )
|
|
|
| -// Factory is the function signature for factory methods compatible with
|
| -// SetFactory.
|
| -type Factory func(context.Context) Interface
|
| +// RawFactory is the function signature for RawFactory methods compatible with
|
| +// SetRawFactory.
|
| +type RawFactory func(context.Context) RawInterface
|
|
|
| -// Filter is the function signature for a filter MC implementation. It
|
| +// RawFilter is the function signature for a RawFilter MC implementation. It
|
| // gets the current MC implementation, and returns a new MC implementation
|
| // backed by the one passed in.
|
| -type Filter func(context.Context, Interface) Interface
|
| +type RawFilter func(context.Context, RawInterface) RawInterface
|
|
|
| -// getUnfiltered gets gets the Interface implementation from context without
|
| +// getUnfiltered gets gets the RawInterface implementation from context without
|
| // any of the filters applied.
|
| -func getUnfiltered(c context.Context) Interface {
|
| - if f, ok := c.Value(memcacheKey).(Factory); ok && f != nil {
|
| +func getUnfiltered(c context.Context) RawInterface {
|
| + if f, ok := c.Value(memcacheKey).(RawFactory); ok && f != nil {
|
| return f(c)
|
| }
|
| return nil
|
| }
|
|
|
| -// Get gets the current memcache implementation from the context.
|
| -func Get(c context.Context) Interface {
|
| +// GetRaw gets the current memcache implementation from the context.
|
| +func GetRaw(c context.Context) RawInterface {
|
| ret := getUnfiltered(c)
|
| if ret == nil {
|
| return nil
|
| @@ -45,34 +45,34 @@ func Get(c context.Context) Interface {
|
| return ret
|
| }
|
|
|
| -// SetFactory sets the function to produce Interface instances, as returned by
|
| +// SetRawFactory sets the function to produce RawInterface instances, as returned by
|
| // the Get method.
|
| -func SetFactory(c context.Context, mcf Factory) context.Context {
|
| +func SetRawFactory(c context.Context, mcf RawFactory) context.Context {
|
| return context.WithValue(c, memcacheKey, mcf)
|
| }
|
|
|
| -// Set sets the current Interface object in the context. Useful for testing
|
| -// with a quick mock. This is just a shorthand SetFactory invocation to set
|
| -// a factory which always returns the same object.
|
| -func Set(c context.Context, mc Interface) context.Context {
|
| - return SetFactory(c, func(context.Context) Interface { return mc })
|
| +// SetRaw sets the current RawInterface object in the context. Useful for testing
|
| +// with a quick mock. This is just a shorthand SetRawFactory invocation to SetRaw
|
| +// a RawFactory which always returns the same object.
|
| +func SetRaw(c context.Context, mc RawInterface) context.Context {
|
| + return SetRawFactory(c, func(context.Context) RawInterface { return mc })
|
| }
|
|
|
| -func getCurFilters(c context.Context) []Filter {
|
| +func getCurFilters(c context.Context) []RawFilter {
|
| curFiltsI := c.Value(memcacheFilterKey)
|
| if curFiltsI != nil {
|
| - return curFiltsI.([]Filter)
|
| + return curFiltsI.([]RawFilter)
|
| }
|
| return nil
|
| }
|
|
|
| -// AddFilters adds Interface filters to the context.
|
| -func AddFilters(c context.Context, filts ...Filter) context.Context {
|
| +// AddRawFilters adds RawInterface filters to the context.
|
| +func AddRawFilters(c context.Context, filts ...RawFilter) context.Context {
|
| if len(filts) == 0 {
|
| return c
|
| }
|
| cur := getCurFilters(c)
|
| - newFilts := make([]Filter, 0, len(cur)+len(filts))
|
| + newFilts := make([]RawFilter, 0, len(cur)+len(filts))
|
| newFilts = append(newFilts, getCurFilters(c)...)
|
| newFilts = append(newFilts, filts...)
|
| return context.WithValue(c, memcacheFilterKey, newFilts)
|
|
|