Merge lp:~sergiusens/account-polld/plugin_interface into lp:~phablet-team/account-polld/trunk

Proposed by Sergio Schvezov
Status: Merged
Approved by: James Henstridge
Approved revision: 3
Merged at revision: 3
Proposed branch: lp:~sergiusens/account-polld/plugin_interface
Merge into: lp:~phablet-team/account-polld/trunk
Diff against target: 80 lines (+75/-0)
1 file modified
plugins/plugins.go (+75/-0)
To merge this branch: bzr merge lp:~sergiusens/account-polld/plugin_interface
Reviewer Review Type Date Requested Status
James Henstridge Approve
Review via email: mp+226060@code.launchpad.net

Description of the change

Proposal for a simple interface for polling plugins.

To post a comment you must log in.
Revision history for this message
James Henstridge (jamesh) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'plugins'
2=== added file 'plugins/plugins.go'
3--- plugins/plugins.go 1970-01-01 00:00:00 +0000
4+++ plugins/plugins.go 2014-07-09 03:14:47 +0000
5@@ -0,0 +1,75 @@
6+/*
7+ Copyright 2014 Canonical Ltd.
8+ Authors: Sergio Schvezov <sergio.schvezov@canonical.com>
9+
10+ This program is free software: you can redistribute it and/or modify it
11+ under the terms of the GNU General Public License version 3, as published
12+ by the Free Software Foundation.
13+
14+ This program is distributed in the hope that it will be useful, but
15+ WITHOUT ANY WARRANTY; without even the implied warranties of
16+ MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17+ PURPOSE. See the GNU General Public License for more details.
18+
19+ You should have received a copy of the GNU General Public License along
20+ with this program. If not, see <http://www.gnu.org/licenses/>.
21+*/
22+
23+package plugins
24+
25+// Plugin is an interface which the plugins will adhere to for the poll
26+// daemon to interact with.
27+//
28+// Poll interacts with the backend service with the means the plugin defines
29+// and returns a list of Notifications to send to the Push service. If an
30+// error occurs and is returned the daemon can decide to throttle the service.
31+//
32+// ApplicationId returns the APP_ID of the delivery target for Post Office.
33+type Plugin interface {
34+ ApplicationId() ApplicationId
35+ Poll(AuthTokens) (*[]Notification, error)
36+}
37+
38+// AuthTokens is a map with tokens the plugins are to use to make requests.
39+type AuthTokens map[string]interface{}
40+
41+// ApplicationId represents the application id to direct posts to.
42+// e.g.: com.ubuntu.diaspora_diaspora or com.ubuntu.diaspora_diaspora_1.0
43+//
44+// TODO define if APP_ID can be of short form
45+// TODO find documentation where short APP_ID is defined (aka versionless APP_ID).
46+type ApplicationId string
47+
48+// Notification represents the data pass over to the Post Office
49+// It's up to the plugin to determine if multiple Notification cards
50+// should be bundled together or to present them separately.
51+//
52+// The daemon can determine to throttle these depending on the
53+// quantity.
54+type Notification struct {
55+ Sound string `json:"sound"`
56+ Card Card `json:"card"`
57+}
58+
59+type Card struct {
60+ Summary string `json:"summary"`
61+ Popup bool `json:"popup"`
62+ Persist bool `json:"persist"`
63+}
64+
65+// The constanst defined here determine the polling aggressivenes with the following criteria
66+// MAXIMUM: calls, health warning
67+// HIGH: SMS, chat message, new email
68+// DEFAULT: social media updates
69+// LOW: software updates, junk email
70+const (
71+ PRIORITY_MAXIMUM = 0
72+ PRIORITY_HIGH
73+ PRIORITY_DEFAULT
74+ PRIORITY_LOW
75+)
76+
77+const (
78+ PLUGIN_EMAIL = 0
79+ PLUGIN_SOCIAL
80+)

Subscribers

People subscribed via source and target branches