public static async Task <ListEventsResponse> NoRetryExample(AuditClient client, ListEventsRequest request) { logger.Info("Starting NoRetryExample"); try { return(await client.ListEvents(request)); } catch (Exception e) { logger.Error($"Failed at NoRetryExample:\n{e}"); throw; } }
public static async Task <ListEventsResponse> RetryExample(AuditClient client, ListEventsRequest request) { logger.Info("Starting RetryExample"); try { return(await client.ListEvents(request, new RetryConfiguration { MaxAttempts = 5 })); } catch (Exception e) { logger.Error($"Failed at RetryExample:\n{e}"); throw; } }
public static async Task <ListEventsResponse> GetEvents(AuditClient client, ListEventsRequest request) { logger.Info("Get events"); try { return(await client.ListEvents(request)); } catch (Exception e) { logger.Error($"Failed at GetEvents:\n{e}"); throw; } }
public static async Task <ListEventsResponse> CancellationTokenExample(AuditClient client, ListEventsRequest request) { logger.Info("Starting CancellationToken Example"); var cts = new CancellationTokenSource(); cts.Cancel(); // Pass cancelled cancellation token to the list events list events operations and verify that // OperationCanceledException is thrown! try { return(await client.ListEvents(request, null, cts.Token)); } catch (OperationCanceledException e) { logger.Info(e.Message); return(null); } catch (Exception e) { logger.Error($"Failed at CancellationTokenExample:\n{e}"); throw; } }