diff options
author | Corey Hulen <corey@hulen.com> | 2015-08-02 09:17:37 -0800 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-08-02 09:17:37 -0800 |
commit | 4d1562c5de377741734a0ad4e8eb30a83d301262 (patch) | |
tree | 74d1d7821b3863231c2d9429b6ccb48728661b30 /Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go | |
parent | adc8def9e06a7908d5f092088922dc26cbb277df (diff) | |
parent | d93bf60248f066542d0851a7b6847f925975d77f (diff) | |
download | chat-4d1562c5de377741734a0ad4e8eb30a83d301262.tar.gz chat-4d1562c5de377741734a0ad4e8eb30a83d301262.tar.bz2 chat-4d1562c5de377741734a0ad4e8eb30a83d301262.zip |
Merge pull request #273 from mattermost/mm-1355
Fixes mm-1355 adds rate limiting apis
Diffstat (limited to 'Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go b/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go new file mode 100644 index 000000000..dbc60fc8e --- /dev/null +++ b/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go @@ -0,0 +1,54 @@ +// Copyright 2014 Gary Burd +// +// Licensed under the Apache License, Version 2.0 (the "License"): you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package internal + +import ( + "strings" +) + +const ( + WatchState = 1 << iota + MultiState + SubscribeState + MonitorState +) + +type CommandInfo struct { + Set, Clear int +} + +var commandInfos = map[string]CommandInfo{ + "WATCH": {Set: WatchState}, + "UNWATCH": {Clear: WatchState}, + "MULTI": {Set: MultiState}, + "EXEC": {Clear: WatchState | MultiState}, + "DISCARD": {Clear: WatchState | MultiState}, + "PSUBSCRIBE": {Set: SubscribeState}, + "SUBSCRIBE": {Set: SubscribeState}, + "MONITOR": {Set: MonitorState}, +} + +func init() { + for n, ci := range commandInfos { + commandInfos[strings.ToLower(n)] = ci + } +} + +func LookupCommandInfo(commandName string) CommandInfo { + if ci, ok := commandInfos[commandName]; ok { + return ci + } + return commandInfos[strings.ToUpper(commandName)] +} |