Skip to content

0.8.0

Choose a tag to compare

@vetcher vetcher released this 12 Mar 09:06
· 30 commits to master since this release
  • Generate // TODO: comments after panics.
  • Style changes to ./middleware/logging.go, ./endpoints.go and ./exchanges.go.
  • Add generation of opentracing #53 :
    • Serves server and client side by wrapping endpoints.
    • Passes spans to headers/meta for http and grpc transports.
  • Add cache middleware #54 :
    • Generates Cache interface:
    type Cache interface {
        Set(key, value interface{}) (err error)
        Get(key interface{}) (value interface{}, err error)
    }
    • Service methods will use first argument as key and all results as value.
    • Or you may add code, which will replace 'key'.
      // @cache-key createdAt.UTC()
    • Useful on client and server sides.
    • You should write your own, or adapt existing storage (e.g. sync.Map).
    type InMemoryCache struct {
    	sync.Map
    }
    
    func (c *InMemoryCache) Set(key, value interface{}) error {
    	c.Store(key, value)
    	return nil
    }
    
    func (c *InMemoryCache) Get(key interface{}) (interface{}, error) {
    	value, _ := c.Load(key) // remember about _
    	return value, nil
    }