aboutsummaryrefslogtreecommitdiffstats
path: root/lib/agent/project-st.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-29 11:19:00 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-29 15:17:45 +0100
commit7c7d90a781082c6bd22d12a5e2451ca61a5198af (patch)
tree980c4ebea211b1a757343296debc39b3aa6b4859 /lib/agent/project-st.go
parentb9239d295a7fb7e3f5c595887b3bf77d50c8b216 (diff)
Renamed apiv1 lib to xaapiv1.
xa prefix (for Xds Agent) is safest to avoid confusion with xs prefix (for Xds Server) Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/agent/project-st.go')
-rw-r--r--lib/agent/project-st.go31
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/agent/project-st.go b/lib/agent/project-st.go
index c4e8fce..d5939e6 100644
--- a/lib/agent/project-st.go
+++ b/lib/agent/project-st.go
@@ -3,8 +3,9 @@ package agent
import (
"fmt"
- "github.com/iotbzh/xds-agent/lib/apiv1"
st "github.com/iotbzh/xds-agent/lib/syncthing"
+ "github.com/iotbzh/xds-agent/lib/xaapiv1"
+ "github.com/iotbzh/xds-server/lib/xsapiv1"
)
// IPROJECT interface implementation for syncthing projects
@@ -13,7 +14,7 @@ import (
type STProject struct {
*Context
server *XdsServer
- folder *XdsFolderConfig
+ folder *xsapiv1.FolderConfig
eventIDs []int
}
@@ -22,13 +23,13 @@ func NewProjectST(ctx *Context, svr *XdsServer) *STProject {
p := STProject{
Context: ctx,
server: svr,
- folder: &XdsFolderConfig{},
+ folder: &xsapiv1.FolderConfig{},
}
return &p
}
// Add a new project
-func (p *STProject) Add(cfg apiv1.ProjectConfig) (*apiv1.ProjectConfig, error) {
+func (p *STProject) Add(cfg xaapiv1.ProjectConfig) (*xaapiv1.ProjectConfig, error) {
var err error
// Add project/folder into XDS Server
@@ -51,7 +52,7 @@ func (p *STProject) Add(cfg apiv1.ProjectConfig) (*apiv1.ProjectConfig, error) {
locPrj, err := p.SThg.FolderConfigGet(id)
if err != nil {
- svrPrj.Status = apiv1.StatusErrorConfig
+ svrPrj.Status = xaapiv1.StatusErrorConfig
return nil, err
}
if svrPrj.ID != locPrj.ID {
@@ -73,14 +74,14 @@ func (p *STProject) Delete() error {
}
// GetProject Get public part of project config
-func (p *STProject) GetProject() *apiv1.ProjectConfig {
+func (p *STProject) GetProject() *xaapiv1.ProjectConfig {
prj := p.server.FolderToProject(*p.folder)
prj.ServerID = p.server.ID
return &prj
}
// Setup Setup local project config
-func (p *STProject) Setup(prj apiv1.ProjectConfig) (*apiv1.ProjectConfig, error) {
+func (p *STProject) Setup(prj xaapiv1.ProjectConfig) (*xaapiv1.ProjectConfig, error) {
// Update folder
p.folder = p.server.ProjectToFolder(prj)
svrPrj := p.GetProject()
@@ -106,7 +107,7 @@ func (p *STProject) Setup(prj apiv1.ProjectConfig) (*apiv1.ProjectConfig, error)
}
// Update Update some field of a project
-func (p *STProject) Update(prj apiv1.ProjectConfig) (*apiv1.ProjectConfig, error) {
+func (p *STProject) Update(prj xaapiv1.ProjectConfig) (*xaapiv1.ProjectConfig, error) {
if p.folder.ID != prj.ID {
return nil, fmt.Errorf("Invalid id")
@@ -146,7 +147,7 @@ func (p *STProject) IsInSync() (bool, error) {
// callback use to update (XDS Server) folder IsInSync status
func (p *STProject) _cbServerFolderChanged(pData interface{}, data interface{}) error {
- evt := data.(XdsEventFolderChange)
+ evt := data.(xsapiv1.EventMsg)
// Only process event that concerns this project/folder ID
if p.folder.ID != evt.Folder.ID {
@@ -159,7 +160,7 @@ func (p *STProject) _cbServerFolderChanged(pData interface{}, data interface{})
p.folder.DataCloudSync.STSvrIsInSync = evt.Folder.IsInSync
p.folder.DataCloudSync.STSvrStatus = evt.Folder.Status
- if err := p.events.Emit(apiv1.EVTProjectChange, p.server.FolderToProject(*p.folder), ""); err != nil {
+ if err := p.events.Emit(xaapiv1.EVTProjectChange, p.server.FolderToProject(*p.folder), ""); err != nil {
p.Log.Warningf("Cannot notify project change (from server): %v", err)
}
}
@@ -180,15 +181,15 @@ func (p *STProject) _cbLocalSTEvents(ev st.Event, data *st.EventsCBData) {
to := ev.Data["to"]
switch to {
case "scanning", "syncing":
- sts = apiv1.StatusSyncing
+ sts = xaapiv1.StatusSyncing
case "idle":
- sts = apiv1.StatusEnable
+ sts = xaapiv1.StatusEnable
}
inSync = (to == "idle")
case st.EventFolderPaused:
- if sts == apiv1.StatusEnable {
- sts = apiv1.StatusPause
+ if sts == xaapiv1.StatusEnable {
+ sts = xaapiv1.StatusPause
}
inSync = false
}
@@ -198,7 +199,7 @@ func (p *STProject) _cbLocalSTEvents(ev st.Event, data *st.EventsCBData) {
p.folder.DataCloudSync.STLocIsInSync = inSync
p.folder.DataCloudSync.STLocStatus = sts
- if err := p.events.Emit(apiv1.EVTProjectChange, p.server.FolderToProject(*p.folder), ""); err != nil {
+ if err := p.events.Emit(xaapiv1.EVTProjectChange, p.server.FolderToProject(*p.folder), ""); err != nil {
p.Log.Warningf("Cannot notify project change (local): %v", err)
}
}