Refactor storage to support shallow types.

Add Client to storage.
Fix client resizing issues.
This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-09-01 20:12:19 -03:00
parent 4b00a9c0eb
commit 954c52471b
25 changed files with 1005 additions and 563 deletions

View File

@@ -1,12 +1,12 @@
package types
type Client struct {
Id string
ViewPort ViewPort
Session *Session
Id string `json:"id" bson:"id"`
SessionId string `json:"session_id"`
ViewPort ViewPort `json:"viewport"`
}
type ViewPort struct {
Rows uint
Cols uint
Rows uint `json:"rows"`
Cols uint `json:"cols"`
}

View File

@@ -3,8 +3,8 @@ package types
import "context"
type Instance struct {
Image string `json:"image" bson:"image"`
Name string `json:"name" bson:"name"`
Image string `json:"image" bson:"image"`
Hostname string `json:"hostname" bson:"hostname"`
IP string `json:"ip" bson:"ip"`
RoutableIP string `json:"routable_ip" bson:"routable_id"`
@@ -17,13 +17,12 @@ type Instance struct {
ProxyHost string `json:"proxy_host" bson:"proxy_host"`
SessionHost string `json:"session_host" bson:"session_host"`
Type string `json:"type" bson:"type"`
Session *Session `json:"-" bson:"-"`
ctx context.Context `json:"-" bson:"-"`
WindowsId string `json:"-" bson:"windows_id"`
ctx context.Context `json:"-" bson:"-"`
}
type WindowsInstance struct {
ID string `bson:"id"`
Id string `bson:"id"`
SessionId string `bson:"session_id"`
}

View File

@@ -6,19 +6,16 @@ import (
)
type Session struct {
Id string `json:"id"`
Instances map[string]*Instance `json:"instances" bson:"-"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
PwdIpAddress string `json:"pwd_ip_address"`
Ready bool `json:"ready"`
Stack string `json:"stack"`
StackName string `json:"stack_name"`
ImageName string `json:"image_name"`
Host string `json:"host"`
Clients []*Client `json:"-" bson:"-"`
WindowsAssigned []*WindowsInstance `json:"-" bson:"-"`
rw sync.Mutex `json:"-"`
Id string `json:"id" bson:"id"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
PwdIpAddress string `json:"pwd_ip_address"`
Ready bool `json:"ready"`
Stack string `json:"stack"`
StackName string `json:"stack_name"`
ImageName string `json:"image_name"`
Host string `json:"host"`
rw sync.Mutex `json:"-"`
}
func (s *Session) Lock() {