C# Class GoogleCloudSamples.Services.BookDetailLookup

A library for the background task of looking up a book in Google's books API.
Datei anzeigen Open project: GoogleCloudPlatform/getting-started-dotnet Class Usage Examples

Public Methods

Method Description
BookDetailLookup ( string projectId, Options options = null, ISimpleLogger logger = null ) : Google.Api.Gax
CreateTopicAndSubscription ( ) : void

Creates the topic and subscription, if they don't already exist. You should call this once at the beginning of your app.

EnqueueBook ( long bookId ) : void

Publish a message asking for a book to be processed.

ParseDate ( string dateString ) : DateTime?

Parse a date time. Return null if it can't be parsed. A single number will be interpreted as a year, and the date returned will be YEAR-01-01.

ProcessBook ( IBookStore bookStore, long bookId ) : void

Look up a book in Google's Books API. Update the book in the book store.

PullLoop ( Action callback, CancellationToken cancellationToken ) : void

Pulls books from the queue and invokes your callback for each book.

StartPullLoop ( IBookStore bookStore, CancellationToken cancellationToken ) : Task
UpdateBookFromJson ( string json, Book book ) : void

Updates book with information parsed from a json response from Google's Books API.

Private Methods

Method Description
PullOnce ( Action callback, CancellationToken cancellationToken ) : void

Makes one call to PubSub.Pull to pull some books from the subscription.

Method Details

BookDetailLookup() public method

public BookDetailLookup ( string projectId, Options options = null, ISimpleLogger logger = null ) : Google.Api.Gax
projectId string
options Options
logger ISimpleLogger
return Google.Api.Gax

CreateTopicAndSubscription() public method

Creates the topic and subscription, if they don't already exist. You should call this once at the beginning of your app.
public CreateTopicAndSubscription ( ) : void
return void

EnqueueBook() public method

Publish a message asking for a book to be processed.
public EnqueueBook ( long bookId ) : void
bookId long
return void

ParseDate() public static method

Parse a date time. Return null if it can't be parsed. A single number will be interpreted as a year, and the date returned will be YEAR-01-01.
public static ParseDate ( string dateString ) : DateTime?
dateString string A string representation of the date.
return DateTime?

ProcessBook() public method

Look up a book in Google's Books API. Update the book in the book store.
public ProcessBook ( IBookStore bookStore, long bookId ) : void
bookStore IBookStore Where the book is stored.
bookId long The id of the book to look up.
return void

PullLoop() public method

Pulls books from the queue and invokes your callback for each book.
public PullLoop ( Action callback, CancellationToken cancellationToken ) : void
callback Action This callback will be invoked for every book. /// Must be thread safe.
cancellationToken System.Threading.CancellationToken Stop looking by cancelling this token. /// Must not be null.
return void

StartPullLoop() public method

public StartPullLoop ( IBookStore bookStore, CancellationToken cancellationToken ) : Task
bookStore IBookStore
cancellationToken System.Threading.CancellationToken
return Task

UpdateBookFromJson() public static method

Updates book with information parsed from a json response from Google's Books API.
public static UpdateBookFromJson ( string json, Book book ) : void
json string A response from Google's Books API.
book GoogleCloudSamples.Models.Book Fields in book will be overwritten.
return void