NewSource newSource
(name string, d Discovery)
| 100 | |
| 101 | //NewSource newSource |
| 102 | func NewSource(name string, d Discovery) (*SourceDiscovery, error) { |
| 103 | |
| 104 | if d == nil || reflect.ValueOf(d).IsNil() { |
| 105 | return nil, ErrorEmptyDiscovery |
| 106 | } |
| 107 | |
| 108 | s := &SourceDiscovery{ |
| 109 | name: name, |
| 110 | discovery: d, |
| 111 | healthCheckHandler: new(health.CheckBox), |
| 112 | services: make(map[string]*common.Service), |
| 113 | locker: sync.RWMutex{}, |
| 114 | } |
| 115 | |
| 116 | d.SetCallback(s.SetServices) |
| 117 | |
| 118 | return s, d.Open() |
| 119 | } |
no test coverage detected