commit | ff45cfed231f5225105894cc2c5a6c757977e4f2 | [log] [tgz] |
---|---|---|
author | Sundar Ramamoorthy <sramamoorthy@apigee.com> | Fri Dec 02 14:40:54 2016 -0800 |
committer | Sundar Ramamoorthy <sramamoorthy@apigee.com> | Fri Dec 02 14:40:54 2016 -0800 |
tree | cd1c79cfc7a601dfcfd857c25bfd47b3c053a2e5 | |
parent | 6e915eb3030fd5d2f28700e9299673a3e9a7924d [diff] |
Make Time Limit confiugrable and in seconds. Added a Neg TC, but it still does not work.
This core plugin for apid connects to the Apigee Change Agent and publishes the data changes events onto the apid Event service. It also coordinates DB initialization for plugins on startup.
name | description |
---|---|
apigeesync_poll_interval | int. seconds. default: 5 |
apigeesync_organization | string. name. required. |
apigeesync_proxy_server_base | string. url. required. |
apigeesync_consumer_key | string. required. |
apigeesync_consumer_secret | string. required. |
ToDo: ApigeeSync currently only receives a new snapshot during startup, so step #4 only happens once. However, it will eventually receive snapshots over time and the sub-steps should be followed at that time. Plugins depending on ApigeeSync for data should assume that it can happen at any time and follow the heuristic below.
Example plugin code:
var ( log apid.LogService // set in initPlugin data apid.DataService unsafeDB apid.DB dbMux sync.RWMutex ) func init() { apid.RegisterPlugin(initPlugin) } func initPlugin(services apid.Services) error { log = services.Log().ForModule("examplePlugin") log.Debug("start init") data = services.Data() return nil } // always use getDB() to safely access current DB func getDB() apid.DB { dbMux.RLock() db := unsafeDB dbMux.RUnlock() return db } func setDB(db apid.DB) { dbMux.Lock() if unsafeDB == nil { // init API on DB initialization (optional) go initAPI() } unsafeDB = db dbMux.Unlock() } func processSnapshot(snapshot *common.Snapshot) { log.Debugf("Snapshot received. Switching to DB version: %s", snapshot.SnapshotInfo) db, err := data.DBVersion(snapshot.SnapshotInfo) if err != nil { log.Panicf("Unable to access database: %v", err) } // init DB as needed (note: DB may exist, use 'CREATE TABLE IF NOT EXISTS' if not explicitly checking) initDB(db) for _, table := range snapshot.Tables { // populate tables from snapshot... } // switch to new database setDB(db) log.Debug("Snapshot processed") }