Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DecoratedService ¶
type DecoratedService interface { thumbnailssvc.ThumbnailServiceHandler }
Interface acting as facade, holding all the interfaces that this thumbnails microservice is expecting to implement. For now, only the thumbnailssvc.ThumbnailServiceHandler is present, but a future configsvc.ConfigServiceHandler is expected to be added here
This interface will also act as the base interface to implement a decorator pattern.
func NewInstrument ¶
func NewInstrument(next DecoratedService, metrics *metrics.Metrics) DecoratedService
NewInstrument returns a service that instruments metrics.
func NewLogging ¶
func NewLogging(next DecoratedService, logger log.Logger) DecoratedService
NewLogging returns a service that logs messages.
func NewTracing ¶
func NewTracing(next DecoratedService) DecoratedService
NewTracing returns a service that instruments traces.
type Decorator ¶
type Decorator struct {
// contains filtered or unexported fields
}
Base type to implement the decorators. It will provide a basic implementation by delegating to the decoratedService
Expected implementations will be like: ```
type MyDecorator struct { Decorator myCustomOpts *opts additionalSrv *srv }
func NewMyDecorator(next DecoratedService, customOpts *customOpts) DecoratedService { ..... return MyDecorator{ Decorator: Decorator{next: next}, myCustomOpts: opts, additionalSrv: srv, } }
```
func (Decorator) GetThumbnail ¶
func (deco Decorator) GetThumbnail(ctx context.Context, req *thumbnailssvc.GetThumbnailRequest, resp *thumbnailssvc.GetThumbnailResponse) error
Base implementation for the GetThumbnail (for the thumbnailssvc). It will just delegate to the underlying decoratedService
Your custom decorator is expected to overwrite this function, but it MUST call the underlying decoratedService at some point ```
func (d MyDecorator) GetThumbnail(ctx context.Context, req *thumbnailssvc.GetThumbnailRequest, resp *thumbnailssvc.GetThumbnailResponse) error { doSomething() err := d.next.GetThumbnail(ctx, req, resp) doAnotherThing() return err }
```