Group: GNU Social P2P/Design/Agent2LocalCore

From LibrePlanet
< Group:GNU Social P2P‎ | Design
Revision as of 23:05, 20 November 2010 by Miron2 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

< Group:GNU Social P2P/Design

Agent to Local Core Protocol

Keys

The Agent has a public key which controls the identity of the user. All values are opaque to the Core and are decrypted on the Agent side. The Agent should have a local cache for performance.

Core Side

Data manipulation:

  • put(path, value, push) - performs store[path] = value, and notifies any friends if push = true
  • get(path) - returns store[path]
  • delete(path) - performs delete store[path]
  • scan(max, path[, seek_path]) - returns paths in sub-tree
  • multiget(max, path [, seek_path]) - return sub-tree

Agent Side

  • on_receive(route, local_prefix) - notification that a send was received

on_receive is a result of a push from a friend.

REST HTTP binding

A simple binding of the Local Core to Agent protocol over HTTP REST. All {} enclosed structures are JSON encoded.

Data manipulation:

put(path, value, push) 
-> PUT '/store/$path?push=$push', { value: $value }
get(path) 
-> GET '/store/$path'

returns { value: $value }

delete(path) 
-> DELETE '/store/$path'

returns number deleted (0 or 1)

scan(max, path, seek_path) 
-> GET '/store/$path/\$scan?seek=$seek_path&max=$max'

\$ designates a literal dollar sign. If $seek_path is specified, jump after that point (useful for paging). Results are in lexicographical order.

returns [ $path* ]

multiget(max, path [, seek_path]) 
-> GET '/store/$path/\$multi?seek=$seek_path&max=$max'

returns [ {path: $path, value: $value}* ]

Callbacks to Agent:

Agent performs:

GET '/event'

This is a blocking call. Possible results:

on_receive(route, path)
-> { type: 'receive', path: $path, success: true, $route }
-> { type: 'receive', path: $path, success: false, $route, message: "..." }

NOTES: