Common Lisp Package: CHILLAX-SERVER

README:

FUNCTION

Public

EMIT (KEY VALUE)

Adds an entry to the current map function results.

HASHGET (HASH &REST KEYS)

Convenience function for recursively accessing hash tables.

SETFHASHGET (NEW-VALUE HASH KEY &REST MORE-KEYS)

Uses the last key given to hashget to insert NEW-VALUE into the hash table returned by the second-to-last key. tl;dr: DWIM SETF function for HASHGET.

LOG-MESSAGE (FORMAT-STRING &REST FORMAT-ARGS)

Like FORMAT, but the resulting string is written to CouchDB's log.

MKHASH (&REST KEYS-AND-VALUES &AUX (TABLE (MAKE-HASH-TABLE TEST #'EQUAL)))

Convenience function for `literal' hash table definition.

Undocumented

STRCAT (STRING &REST MORE-STRINGS)

Private

ADD-FUN (STRING)

Compiles and adds a function whose source code is in STRING to the current list of active CouchDB functions.

CALL-MAP-FUNCTION (FUNCTION DOC &AUX *MAP-RESULTS*)

Calls a stored compile function on a document. *MAP-RESULTS* is where EMIT will send k/v pairs.

COMPILE-VIEW-FUNCTION (STRING)

Compiles an anonymous function from STRING.

ENSURE-VIEW-FUNCTION (MAYBE-FUNCTION)

Returns a compiled lisp function. MAYBE-FUNCTION can be a function object or a string with the source code to compile a function from.

FILTER (DOCS REQ USER-CONTEXT)

Responds to CouchDB with the result of filtering DOCS using the current filter function.

MAP-DOC (DOC)

Responds to CouchDB with the results of calling all the currently-active map functions on DOC.

REDUCE-RESULTS (FUN-STRINGS KEYS-AND-VALUES)

Responds to CouchDb with the results of calling the functions in FUN-STRINGS on KEYS-AND-VALUES.

REREDUCE (FUN-STRINGS VALUES)

Responds to CouchDB with the results of rereducing FUN-STRINGS on VALUES.

RESET (&OPTIONAL CONFIG)

Resets the view server. Any caches should be emptied at this point, and any stored map functions should be cleared out.

RUN-SERVER (&AUX *FUNCTIONS* (BLACK-HOLE (MAKE-BROADCAST-STREAM)) (*ERROR-OUTPUT* BLACK-HOLE) (*DEBUG-IO* BLACK-HOLE) (*TRACE-OUTPUT* BLACK-HOLE))

Toplevel function that parses view requests from CouchDB and sends responses back.

SHOW (FUN-STRING DOC REQUEST)

Show functions are used to render documents. See CouchDB documentation for more details.

UPDATE (FUN-STRING DOC REQUEST)

See CouchDB documentation for how to use _update. Functions written for the Chillax view server should return (values document response).

VALIDATE (FUN-STRING NEW-DOC OLD-DOC USER-CONTEXT)

Executes a view function that validates NEW-DOC as a new version of OLD-DOC. Validation passes when the function returns normally. Validation will fail if the function errors in any way, and the condition's name and printout will be send to CouchDB as the exception.

Undocumented

CALL-USER-FUNCTION (FUNCTION &REST ARGS)

ENSURE-RESPONSE (MAYBE-RESPONSE)

RESPOND (RESPONSE)

MACRO

Public

FUN (&BODY BODY)

This macro puts the FUN back in FUNCTION.

Private

WITH-USER-PACKAGE (&BODY BODY)

Evaluates BODY in the :chillax-server-user package.

GENERIC-FUNCTION

Private

Undocumented

FAILURE-MESSAGE (CONDITION)

FUNCTION-STRING (CONDITION)

VARIABLE

Public

*DECODE-JSON*

Function to use to decode JSON->Lisp. Must accept a string.

*ENCODE-JSON*

Function to use when encoding Lisp->JSON. Must return a string.

*USER-PACKAGE*

Package that user view functions will be compiled and executed in.

Private

*DISPATCH*

Dispatch table holding Couch command -> Chillax function associations.

*FUNCTION-CACHE*

Cache of compiled user functions. This is cleared whenever the reset command is run.

Undocumented

*CONFIG*

CONDITION

Public

Undocumented

FORBIDDEN

VALIDATION-FAILURE

Private

Undocumented

CHILLAX-SERVER-ERROR

FUNCTION-COMPILATION-ERROR