diff options
author | =Corey Hulen <corey@hulen.com> | 2015-07-21 12:26:27 -0800 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-07-21 12:26:27 -0800 |
commit | 848eeeeef4ed277ceb00d3fc6c8a0303c0e72d09 (patch) | |
tree | 98390442e8052b8e02469e5ccf7596e22b7ea07f /store/redis.go | |
parent | e87adce4a059b97a65198b326be6304abdf4e657 (diff) | |
parent | bee26e3f2654ce7acce647818847480569236343 (diff) | |
download | chat-848eeeeef4ed277ceb00d3fc6c8a0303c0e72d09.tar.gz chat-848eeeeef4ed277ceb00d3fc6c8a0303c0e72d09.tar.bz2 chat-848eeeeef4ed277ceb00d3fc6c8a0303c0e72d09.zip |
fixing merge conflicts
Diffstat (limited to 'store/redis.go')
-rw-r--r-- | store/redis.go | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/store/redis.go b/store/redis.go deleted file mode 100644 index 262040d43..000000000 --- a/store/redis.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. -// See License.txt for license information. - -package store - -import ( - l4g "code.google.com/p/log4go" - "github.com/mattermost/platform/model" - "github.com/mattermost/platform/utils" - "gopkg.in/redis.v2" - "strings" - "time" -) - -var client *redis.Client - -func RedisClient() *redis.Client { - - if client == nil { - - addr := utils.Cfg.RedisSettings.DataSource - - client = redis.NewTCPClient(&redis.Options{ - Addr: addr, - Password: "", - DB: 0, - PoolSize: utils.Cfg.RedisSettings.MaxOpenConns, - }) - - l4g.Info("Pinging redis at '%v'", addr) - pong, err := client.Ping().Result() - - if err != nil { - l4g.Critical("Failed to open redis connection to '%v' err:%v", addr, err) - time.Sleep(time.Second) - panic("Failed to open redis connection " + err.Error()) - } - - if pong != "PONG" { - l4g.Critical("Failed to ping redis connection to '%v' err:%v", addr, err) - time.Sleep(time.Second) - panic("Failed to open ping connection " + err.Error()) - } - } - - return client -} - -func RedisClose() { - l4g.Info("Closing redis") - - if client != nil { - client.Close() - client = nil - } -} - -func PublishAndForget(message *model.Message) { - - go func() { - c := RedisClient() - result := c.Publish(message.TeamId, message.ToJson()) - if result.Err() != nil { - l4g.Error("Failed to publish message err=%v, payload=%v", result.Err(), message.ToJson()) - } - }() -} - -func GetMessageFromPayload(m interface{}) *model.Message { - if msg, found := m.(*redis.Message); found { - return model.MessageFromJson(strings.NewReader(msg.Payload)) - } else { - return nil - } -} |