droonga / express-droonga

A framework for building scalable realtime web API services
https://npmjs.org/package/express-droonga
MIT License
5 stars 2 forks source link

Design envelope to communicate with kotoumi #2

Closed piroor closed 11 years ago

piroor commented 11 years ago

Express-kotoumi will send a JSON string to kotoumi, and receive the result as a JSON string. We have to design the envelope and the body.

piroor commented 11 years ago

Envelope

request or signal:

{
  id: "0123456789",
  date: "2013-01-07T13:00:00+09:00",
  body: "{...}"
}

response:

{
  id: "abcdefg",
  date: "2013-01-07T13:00:00+09:00",
  replyTo: "0123456789",
  body: "{...}"
}
piroor commented 11 years ago

The format of the body depends on the request type. So it should be discussed as another issue.

piroor commented 11 years ago

Should we include the statusCode in #3 in the envelope?

{
  id: "abcdefg",
  date: "2013-01-07T13:00:00+09:00",
  replyTo: "0123456789",
  statusCode: 200,
  body: "{...}"
}
piroor commented 11 years ago

Should we use UNIX time for "date"?

{
  id: "abcdefg",
  date: "1357545175",
  body: "{...}"
}

Note: the value should be string instead of integer, because JavaScript cannot handle very large number.

piroor commented 11 years ago
piroor commented 11 years ago

request/push:

{
  id: "0123456789",
  date: "2001-08-02T10:45:23.5+09:00",
  statusCode: 200, // optional
  type: "search-request", // create-table, remove-table, etc.
  body: "{...}"
}

response:

{
  id: "abcdefg",
  date: "2001-08-02T10:45:23.5+09:00",
  replyTo: "0123456789",
  statusCode: 200,
  type: "search-result", // create-table-result, remove-table-result, etc.
  body: "{...}"
}
piroor commented 11 years ago

To indicate more detailed timestamps, we've decided to use the format: "YYYY-MM-DDThh:mm:ss.sTZD"

ex. 2001-08-02T10:45:23.5+09:00

See: http://www.kanzaki.com/docs/html/dtf.html#w3cdtf

piroor commented 11 years ago

Done.