-
Notifications
You must be signed in to change notification settings - Fork 33
/
session.go
43 lines (37 loc) · 1013 Bytes
/
session.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package model
import (
"github.com/viant/gosh"
"sync"
)
// Session represents a system terminal session
type Session struct {
ID string
*gosh.Service
DaemonType int
Username string
SuperUSerAuth bool
//Path *Path
EnvVariables map[string]string
CurrentDirectory string
Deployed map[string]string
Cacheable map[string]interface{}
Mutex *sync.RWMutex
}
// NewSession create a new client session
func NewSession(id string, connection *gosh.Service) (*Session, error) {
return &Session{
ID: id,
Service: connection,
EnvVariables: make(map[string]string),
Deployed: make(map[string]string),
Cacheable: make(map[string]interface{}),
Mutex: &sync.RWMutex{},
}, nil
}
// Sessions represents a map of client sessions keyed by session id
type Sessions map[string]*Session
// Has checks if client session exists for provided id.
func (s *Sessions) Has(id string) bool {
_, has := (*s)[id]
return has
}