More fixes

This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-07-28 23:24:02 -03:00
parent 0e08107738
commit 5ee4bb2011
14 changed files with 125 additions and 49 deletions

View File

@@ -48,7 +48,22 @@ func (store *storage) SessionPut(s *types.Session) error {
return store.save()
}
func (store *storage) InstanceFind(sessionId, ip string) (*types.Instance, error) {
func (store *storage) InstanceGet(sessionId, name string) (*types.Instance, error) {
store.rw.Lock()
defer store.rw.Unlock()
s := store.db[sessionId]
if s == nil {
return nil, fmt.Errorf("%s", notFound)
}
i := s.Instances[name]
if i == nil {
return nil, fmt.Errorf("%s", notFound)
}
return i, nil
}
func (store *storage) InstanceFindByIP(sessionId, ip string) (*types.Instance, error) {
store.rw.Lock()
defer store.rw.Unlock()
@@ -116,19 +131,6 @@ func (store *storage) InstanceCount() (int, error) {
return ins, nil
}
func (store *storage) ClientCount() (int, error) {
store.rw.Lock()
defer store.rw.Unlock()
var cli int
for _, s := range store.db {
cli += len(s.Clients)
}
return cli, nil
}
func (store *storage) SessionDelete(sessionId string) error {
store.rw.Lock()
defer store.rw.Unlock()