Storage has now it's own package.

Remove global `sessions` map and use configured storage.
Add a `types` package so both `pwd` and `storage` can access without
circular dependencies.
Now the session is prepared when requested and not on load.
This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-06-14 18:35:21 -03:00
parent 2eff799c58
commit e9911abf94
22 changed files with 814 additions and 499 deletions

23
storage/storage.go Normal file
View File

@@ -0,0 +1,23 @@
package storage
import "github.com/play-with-docker/play-with-docker/pwd/types"
const notFound = "NotFound"
func NotFound(e error) bool {
return e.Error() == notFound
}
type StorageApi interface {
SessionGet(sessionId string) (*types.Session, error)
SessionPut(*types.Session) error
SessionCount() (int, error)
SessionDelete(sessionId string) error
InstanceFindByAlias(sessionPrefix, alias string) (*types.Instance, error)
// Should have the session id too, soon
InstanceFindByIP(ip string) (*types.Instance, error)
InstanceCount() (int, error)
ClientCount() (int, error)
}