C# Class GoogleCloudSamples.Services.BookDetailLookup

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

Méthodes publiques

Méthode 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

Méthode Description
PullOnce ( Action callback, CancellationToken cancellationToken ) : void

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

Method Details

BookDetailLookup() public méthode

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

CreateTopicAndSubscription() public méthode

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
Résultat void

EnqueueBook() public méthode

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

ParseDate() public static méthode

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.
Résultat DateTime?

ProcessBook() public méthode

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.
Résultat void

PullLoop() public méthode

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.
Résultat void

StartPullLoop() public méthode

public StartPullLoop ( IBookStore bookStore, CancellationToken cancellationToken ) : Task
bookStore IBookStore
cancellationToken System.Threading.CancellationToken
Résultat Task

UpdateBookFromJson() public static méthode

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.
Résultat void