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:
23
storage/storage.go
Normal file
23
storage/storage.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user