NewEndpointer creates an Endpointer that subscribes to updates from Instancer src and uses factory f to create Endpoints. If src notifies of an error, the Endpointer keeps returning previously created Endpoints assuming they are still good, unless this behavior is disabled via InvalidateOnError opti
(src Instancer, f Factory, logger log.Logger, options ...EndpointerOption)
| 26 | // keeps returning previously created Endpoints assuming they are still good, unless |
| 27 | // this behavior is disabled via InvalidateOnError option. |
| 28 | func NewEndpointer(src Instancer, f Factory, logger log.Logger, options ...EndpointerOption) *DefaultEndpointer { |
| 29 | opts := endpointerOptions{} |
| 30 | for _, opt := range options { |
| 31 | opt(&opts) |
| 32 | } |
| 33 | se := &DefaultEndpointer{ |
| 34 | cache: newEndpointCache(f, logger, opts), |
| 35 | instancer: src, |
| 36 | ch: make(chan Event), |
| 37 | } |
| 38 | go se.receive() |
| 39 | src.Register(se.ch) |
| 40 | return se |
| 41 | } |
| 42 | |
| 43 | // EndpointerOption allows control of endpointCache behavior. |
| 44 | type EndpointerOption func(*endpointerOptions) |
searching dependent graphs…