aboutsummaryrefslogtreecommitdiff
path: root/lib/Net.Rest.Client/src/ClientPool.cs
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-03-19 13:12:28 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2023-03-19 13:12:28 -0400
commitd066a3d7ec26fd6919c514aeaccc4d6b086dc9c7 (patch)
treedd34663e8513f4b00a6bf326b33e2f9710da3dc3 /lib/Net.Rest.Client/src/ClientPool.cs
parent36f1c3db6df08c5abb098bfe049b30fc443fbb5c (diff)
RestSharp update, JWT api open up/change
Diffstat (limited to 'lib/Net.Rest.Client/src/ClientPool.cs')
-rw-r--r--lib/Net.Rest.Client/src/ClientPool.cs71
1 files changed, 0 insertions, 71 deletions
diff --git a/lib/Net.Rest.Client/src/ClientPool.cs b/lib/Net.Rest.Client/src/ClientPool.cs
deleted file mode 100644
index 7d3bbd0..0000000
--- a/lib/Net.Rest.Client/src/ClientPool.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-* Copyright (c) 2022 Vaughn Nugent
-*
-* Library: VNLib
-* Package: VNLib.Net.Rest.Client
-* File: ClientPool.cs
-*
-* ClientPool.cs is part of VNLib.Net.Rest.Client which is part of the larger
-* VNLib collection of libraries and utilities.
-*
-* VNLib.Net.Rest.Client is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published
-* by the Free Software Foundation, either version 2 of the License,
-* or (at your option) any later version.
-*
-* VNLib.Net.Rest.Client is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with VNLib.Net.Rest.Client. If not, see http://www.gnu.org/licenses/.
-*/
-
-using System;
-
-using RestSharp;
-using RestSharp.Authenticators;
-
-using VNLib.Utils.Memory.Caching;
-
-#nullable enable
-
-namespace VNLib.Net.Rest.Client
-{
- /// <summary>
- /// Maintains a pool of lazy loaded <see cref="RestClient"/> instances to allow for concurrent client usage
- /// </summary>
- public class RestClientPool : ObjectRental<RestClient>
- {
- /// <summary>
- /// Creates a new <see cref="RestClientPool"/> instance and creates the specified
- /// number of clients with the same number of concurrency.
- /// </summary>
- /// <param name="maxClients">The maximum number of clients to create and authenticate, should be the same as the number of maximum allowed tokens</param>
- /// <param name="options">A <see cref="RestClientOptions"/> used to initialze the pool of clients</param>
- /// <param name="authenticator">An optional authenticator for clients to use</param>
- /// <param name="initCb">An optional client initialzation callback</param>
- public RestClientPool(int maxClients, RestClientOptions options, Action<RestClient>? initCb = null, IAuthenticator? authenticator = null)
- : base(() =>
- {
- RestClient client = new(options);
- //Add optional authenticator
- if (authenticator != null)
- {
- client.UseAuthenticator(authenticator);
- }
- //Invoke init callback
- initCb?.Invoke(client);
- return client;
- }, null, null, maxClients)
- {
- }
-
- /// <summary>
- /// Obtains a new <see cref="ClientContract"/> for a reused, or new, <see cref="RestClient"/> instance
- /// </summary>
- /// <returns>The contract that manages the client</returns>
- public ClientContract Lease() => new(base.Rent(), this);
- }
-}