Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrency of key #2

Open
AssCasc opened this issue Mar 26, 2024 · 3 comments
Open

Concurrency of key #2

AssCasc opened this issue Mar 26, 2024 · 3 comments

Comments

@AssCasc
Copy link

AssCasc commented Mar 26, 2024

According to the getting started, api-key and pertner-key must be stored in "Configuration.Default.ApiKey" dictionary; in this way the kays are shared to all library.
In my case i need use the library in large shared service with hundreds of Brevo connections. You will understand that I cannot use shared keys throughout the library but each connection requires its own keys. I need something like that:

using System;
using System.Diagnostics;
using sib_api_v3_sdk.Api;
using sib_api_v3_sdk.Client;
using sib_api_v3_sdk.Model;

namespace Example
{
    public class Example
    {
        public void main()
        {

              var apiInstance = new AccountApi(api-key, partner-key);

            try
            {
                // Get your account information, plan and credits details
                GetAccount result = apiInstance.GetAccount();
                Debug.WriteLine(result);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling AccountApi.GetAccount: " + e.Message );
            }

        }
    }
}

Is this possible? Or if i fork the project you will accept the update?

@PatrickKunz
Copy link

Please merge the pull request. Singletons are not a good solution in multithreaded applications, especially when they offer direct write access to a list.

@AssCasc
Copy link
Author

AssCasc commented Aug 26, 2024

Sorry i forgot to write in this thread but after doing all the conversion work i realized that it is possible to use:

Dim brevoConfig As New Configuration()
brevoConfig.ApiKey.Add("api-key", your-api-key)
Dim apiInstance As New AccountApi(brevoConfig)

to set the api key specifically for this invocation

@PatrickKunz
Copy link

Thanks for the information. Didn't notice that :) The examples should also use this instead of the singleton.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants