X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=lib%2Fsyncthing%2FstEvent.go;h=ec11b56e0f894ef2c6161bac7162f19c7901832b;hb=refs%2Fchanges%2F61%2F19061%2F2;hp=948f88a6fb45e52d58ba21481cf29d2fb792a071;hpb=285332c351777b74abca638b8b2a2cde3c68edc6;p=src%2Fxds%2Fxds-server.git diff --git a/lib/syncthing/stEvent.go b/lib/syncthing/stEvent.go index 948f88a..ec11b56 100644 --- a/lib/syncthing/stEvent.go +++ b/lib/syncthing/stEvent.go @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 "IoT.bzh" + * Copyright (C) 2017-2018 "IoT.bzh" * Author Sebastien Douheret * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,32 +42,44 @@ type Events struct { mutex sync.Mutex } +// Event Syncthing events structure type Event struct { Type string `json:"type"` Time time.Time `json:"time"` Data map[string]string `json:"data"` } +// EventsCBData Data parameter of Event callback type EventsCBData map[string]interface{} + +// EventsCB Event callback type EventsCB func(ev Event, cbData *EventsCBData) const ( + // EventFolderCompletion . EventFolderCompletion string = "FolderCompletion" - EventFolderSummary string = "FolderSummary" - EventFolderPaused string = "FolderPaused" - EventFolderResumed string = "FolderResumed" - EventFolderErrors string = "FolderErrors" - EventStateChanged string = "StateChanged" + // EventFolderSummary . + EventFolderSummary string = "FolderSummary" + // EventFolderPaused . + EventFolderPaused string = "FolderPaused" + // EventFolderResumed . + EventFolderResumed string = "FolderResumed" + // EventFolderErrors . + EventFolderErrors string = "FolderErrors" + // EventStateChanged . + EventStateChanged string = "StateChanged" ) -var EventsAll string = EventFolderCompletion + "|" + +// EventsAll . +var EventsAll = EventFolderCompletion + "|" + EventFolderSummary + "|" + EventFolderPaused + "|" + EventFolderResumed + "|" + EventFolderErrors + "|" + EventStateChanged -type STEvent struct { +// SyncthingEvent Syncthing Event structure definition +type SyncthingEvent struct { // Per-subscription sequential event ID. Named "id" for backwards compatibility with the REST API SubscriptionID int `json:"id"` // Global ID of the event across all subscriptions @@ -158,9 +170,9 @@ func (e *Events) UnRegister(id string) error { } // GetEvents returns the Syncthing events -func (e *Events) getEvents(since int) ([]STEvent, error) { +func (e *Events) getEvents(since int) ([]SyncthingEvent, error) { var data []byte - ev := []STEvent{} + ev := []SyncthingEvent{} url := "events" if since != -1 { url += "?since=" + strconv.Itoa(since)