summaryrefslogtreecommitdiffstats
path: root/bridge/bridge.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-02-23 22:51:27 +0100
committerGitHub <noreply@github.com>2019-02-23 22:51:27 +0100
commitbf21604d425b4feb1b95e4e94643e7a658eeea90 (patch)
tree376741188b9646ef66526b36e24d3577f07a678f /bridge/bridge.go
parent1bb39eba8717f62336cc98c5bb7cfbef194f3626 (diff)
downloadmatterbridge-msglm-bf21604d425b4feb1b95e4e94643e7a658eeea90.tar.gz
matterbridge-msglm-bf21604d425b4feb1b95e4e94643e7a658eeea90.tar.bz2
matterbridge-msglm-bf21604d425b4feb1b95e4e94643e7a658eeea90.zip
Make all loggers derive from non-default instance (#728)
Diffstat (limited to 'bridge/bridge.go')
-rw-r--r--bridge/bridge.go31
1 files changed, 15 insertions, 16 deletions
diff --git a/bridge/bridge.go b/bridge/bridge.go
index 6b955a9e..fdc1ec8b 100644
--- a/bridge/bridge.go
+++ b/bridge/bridge.go
@@ -2,10 +2,10 @@ package bridge
import (
"strings"
+ "sync"
"github.com/42wim/matterbridge/bridge/config"
"github.com/sirupsen/logrus"
- "sync"
)
type Bridger interface {
@@ -17,6 +17,8 @@ type Bridger interface {
type Bridge struct {
Bridger
+ *sync.RWMutex
+
Name string
Account string
Protocol string
@@ -26,37 +28,34 @@ type Bridge struct {
Log *logrus.Entry
Config config.Config
General *config.Protocol
- *sync.RWMutex
}
type Config struct {
- // General *config.Protocol
- Remote chan config.Message
- Log *logrus.Entry
*Bridge
+
+ Remote chan config.Message
}
// Factory is the factory function to create a bridge
type Factory func(*Config) Bridger
func New(bridge *config.Bridge) *Bridge {
- b := &Bridge{
- Channels: make(map[string]config.ChannelInfo),
- RWMutex: new(sync.RWMutex),
- Joined: make(map[string]bool),
- }
accInfo := strings.Split(bridge.Account, ".")
protocol := accInfo[0]
name := accInfo[1]
- b.Name = name
- b.Protocol = protocol
- b.Account = bridge.Account
- return b
+
+ return &Bridge{
+ RWMutex: new(sync.RWMutex),
+ Channels: make(map[string]config.ChannelInfo),
+ Name: name,
+ Protocol: protocol,
+ Account: bridge.Account,
+ Joined: make(map[string]bool),
+ }
}
func (b *Bridge) JoinChannels() error {
- err := b.joinChannels(b.Channels, b.Joined)
- return err
+ return b.joinChannels(b.Channels, b.Joined)
}
// SetChannelMembers sets the newMembers to the bridge ChannelMembers