NonBlocking (Async) Tornado Presentation for Charlotte Python Group
There are slides and example code. I had a lot of fun making and giving this presentation. Got some good feedback and would like to give it again so I can continue to improve it and my presentation skill. Please give me feedback to improve the presentation or let me know if any other groups would be interested in it.
Tuesday, August 31, 2010
Thursday, August 12, 2010
goriak API tweaks
My initial attempt at coding goriak was a mess (as expected). As I started adding read,write and links to the API I started to realize the failing of my modeling. The new API is based on a Document struct:
// Define a basic document to reduce API calls
type Document struct {
Bucket string
Key string
Value []byte
Links []*Link
JSONObject interface{}
}
This encapsulates most of the values that I was passing as parameters to the functions. Since Riak is a key/value it is pretty straight forward that a Put(doc) will store the for the string Key the bytes in Value. However if JSONObject != nil then it will marshal it. This works in reverse for Get(doc) if the JSONObject != nil then it will unmarshal.
// Definition of a link from one document to another
type Link struct {
Bucket string
Key string
Tag string
}
Link between documents is such a simple feature but is also very powerful. Using links can quickly turn a key/value database into a graph. Specifically with the linkwalking that will allow traversal of the graph. To support it I just had to parse and set the header "Link:". Both Put and Get now support storing or retrieving the list of Links associated with a document.
The API now:
PutWDWReturn(doc *Document, w, dw int, returnObject bool)
Put(doc *Document)
DeleteRW(bucketName, key string, rw int)
Delete(bucketName, key string)
GetR(doc *Document, r int)
Get(doc *Document)
The methods with r,w,dw and rw are all wrappers around the Riak REST API. The default is to use whatever the bucket is configured for node persistence control. Since the expectation is the exception that to override the bucket default configuration I provide the wrapper like Get that wraps GetR to save typing.
Next on my list to implement is LinkWalking!
Next on my list to implement is LinkWalking!
Subscribe to:
Posts (Atom)