Tuesday, January 21, 2014

Updates

I didn't post anything in the last months, so I'll have a small update on the library.
1.7.0-beta was announced several weeks ago and meantime I even joined a new team in Google (I'll write more on it in the next posts).
I'm still working on "my baby" and the plan is to reach GA (and remove the beta label from it) by the end of March. In addition, I also work on improving the documentation of the library, hopefully you will get it soon :)

In the last release I introduced the Google.Apis.Core package which contains shared types and logic to the Google.Apis and Google.Apis.Auth packages. It contains Logging, Http, JSON and other utility components. It has no effect on our users, it is just a nice separation between the client's components.

Besides fixing several bugs I also added a batch implementation to the library. You can read more on the protocol in this page, and the .NET implementation of this protocol is described here.
Small code snippet on how to use BatchRequest:

// Create the service.
var service = new CalendarService( ... );

// Create the batch request.
var request = new BatchRequest(service);
request.Queue<CalendarList>(service.CalendarList.List(),
    (content, error, index, message) =>
    {
        // In case the request succeeded the ‘content’ contains the CalendarList object,
        // otherwise ‘error’ contains the HTTP error.
    });
// You can add more individual request to your batch request by calling to:
// request.Queue<....

// Executes the batch request which composed form the all the required requests.
await request.ExecuteAsync();

As you can see you should add a callback when calling to Queue which gets the following parameters:

  • content - The content object of the response. In the case above it will contain the returned CalendarList object.
  • error - In case the individual request has failed, this parameter will contain the error.
  • index - The request's index. In the example above the index is 0.
  • message - The full HttpResponseMessage with all its headers and content.


And this time... the photos of this post were taken in October 2011 in the most southern city in the world - Ushuaia.

1 comment:

  1. Hi Eyal , Would you please tell me the benefits of Batchrequest in Google Api? Suppose, I have migrated several emails to outlook and the next time I have to migrate some more emails, how would I know I am not migrating duplicates emails ? Could Batchrequest would help me in this regard?

    best regards,

    ReplyDelete