modify drivers
This commit is contained in:
@@ -6,7 +6,7 @@ type Driver struct {
|
||||
Buses map[string]*Bus `json:"buses"` // name of driver bus
|
||||
}
|
||||
|
||||
func (d *Driver) AddBus(name string) *Bus {
|
||||
func (d *Driver) AddNewBus(name string) *Bus {
|
||||
if d.Buses == nil {
|
||||
d.Buses = make(map[string]*Bus)
|
||||
}
|
||||
@@ -17,6 +17,24 @@ func (d *Driver) AddBus(name string) *Bus {
|
||||
return d.Buses[name]
|
||||
}
|
||||
|
||||
func (d *Driver) AddBuses(buses map[string]*Bus) {
|
||||
if d.Buses == nil {
|
||||
d.Buses = make(map[string]*Bus)
|
||||
}
|
||||
for key, newBus := range buses {
|
||||
if currentBus, ok := d.Buses[key]; ok {
|
||||
currentBus.AddAddress(newBus.Address...)
|
||||
if newBus.Topic == nil {
|
||||
continue
|
||||
}
|
||||
currentBus.AddSubscription(newBus.Topic.Subscribe...)
|
||||
currentBus.AddPublish(newBus.Topic.Publish...)
|
||||
continue
|
||||
}
|
||||
d.Buses[key] = newBus
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Driver) GetBus(name string) *Bus {
|
||||
if b, ok := d.Buses[name]; ok {
|
||||
return b
|
||||
|
Reference in New Issue
Block a user