[openstack-dev] [Oslo] jsonutils support for datetimes

Joshua Harlow harlowja at yahoo-inc.com
Mon Jun 3 17:41:12 UTC 2013


You guys seem to be getting into an area where avro has done a lot of work
here ;)

http://avro.apache.org/docs/current/spec.html#schemas

{
  "type": "record",
  "name": "LongList",
  "aliases": ["LinkedLongs"],                      // old name for this
  "fields" : [
    {"name": "value", "type": "long"},             // each element has a
long
    {"name": "next", "type": ["LongList", "null"]} // optional next element
  ]
}


That starts to look any awfully lot like what u might be trying to do ;)

An example of the datetime issue (still unresolved sadly)

https://issues.apache.org/jira/browse/AVRO-739

{
    "type": "record",
    "name": "org.apache.avro.lib.Date",
    "fields": [
        {
            "name": "time",
            "type": "long"
        }
    ]
}


I wonder if we should start looking at avro and its usage in openstack?


On 6/3/13 10:10 AM, "Flavio Percoco" <flavio at redhat.com> wrote:

>On 03/06/13 09:14 -0400, Doug Hellmann wrote:
>>   On Mon, Jun 3, 2013 at 7:33 AM, Flavio Percoco <[1]flavio at redhat.com>
>>   wrote:
>>         3) Serialize the datetime as a dictionary with the following
>>         structure:
>>             {"_type": "datetime",          "_value": "....",
>>     "_format": "%Y-%m-%dT%H:%M:%S.%f"}
>>                 The above will allow the de-serializer to know whether
>>     it
>>             should be converted, the object type (datetime, date or
>>     time)
>>             and the format it was serialized with. I don't like this
>>     idea
>>             but I see the benefit of having all that information.
>>
>>   You could also just include the _type and _value, leaving the
>>   interpretation of that value up to the receiver.
>
>Interesting, might make sense. I'll try this as well.
>
>I guess the default format would be specified in the Deserializer
>instance or the loads call.
>
>>   At the summit there was a proposal in the nova track to support
>>sending
>>   arbitrary objects over RPC transparently as part of the versioned
>>   object session [1]. I think the final proposal involved using a
>>   registry of types with serializers and deserializers. Datetimes could
>>   just be another type in that registry system.
>
>mmh, didn't know about this. I'll dig more on the proposal.
>
>Cheers,
>FF
>
>-- 
>@flaper87
>Flavio Percoco
>
>_______________________________________________
>OpenStack-dev mailing list
>OpenStack-dev at lists.openstack.org
>http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev




More information about the OpenStack-dev mailing list