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

Subscribers

People subscribed via source and target branches