1
0
mirror of https://github.com/bingohuang/docker-labs.git synced 2025-10-04 17:33:21 +08:00

Add expiration clock to sessions

This commit is contained in:
Jonathan Leibiusky @xetorthio
2016-11-15 13:20:59 -03:00
parent 939c045198
commit db074a5804
4 changed files with 23 additions and 0 deletions

View File

@@ -19,6 +19,8 @@ type Session struct {
Id string `json:"id"`
Instances map[string]*Instance `json:"instances"`
clients []*Client `json:"-"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
}
func (s *Session) Lock() {
@@ -87,6 +89,8 @@ func NewSession() (*Session, error) {
s := &Session{}
s.Id = uuid.NewV4().String()
s.Instances = map[string]*Instance{}
s.CreatedAt = time.Now()
s.ExpiresAt = s.CreatedAt.Add(4 * time.Hour)
log.Printf("NewSession id=[%s]\n", s.Id)
sessions[s.Id] = s