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

Multiple Configuration / Clients #42

Conversation

apemaia99
Copy link

  • Now is possible to load multiple configurations, this is essential in order to send push notifications to different apps.
  • Multiple clients are instantiated based on different configuration provided.
  • FCM.ID is a convenience struct for identifying a specific client with a specific configuration.

…ssible to handle multiple clients at same time since he were looking up for config into application.storage (same for all).

F added FCM.Storage layer to store hash map of multiple clients with relative configuration based on FCM.ID utility struct for identifying a client around your application.
@MihaelIsaev
Copy link
Owner

Hey @apemaia99 thanks for that great contribution! Sorry that it took so long to review it. It would be great if you also could update readme for these changes and I'd love to tag it as v3.0.0

@apemaia99
Copy link
Author

Hey @MihaelIsaev, I'm happy for that, but unfortunately I found out a bug that I need to address before proceeding.
Since my implementation allows multiple clients at same time, each client tries to find the same KEY in the environment this can be very dangerous, I need to find another solution. Personally I don't use the env keys as configuration method and that's why I didn't catch it early in the development.

R removed nil coalescing on default env keys, this can lead to a misbehavior when used with multiple instances.
F added EnvironmentKeys enum that holds all possible env keys lookups already used
F added specific lookup function in order to retrieve right value from environment based on correct FCM instance. In case of default instance, the current keys will be used without performing any concatenation in order to not break current api.
@apemaia99
Copy link
Author

@MihaelIsaev I've found a solution for getting right keys based on FCM.ID, I try to explain it with an example.

let's take as example email env key "FCM_EMAIL", in this case:

  • If used on a specific instance (A as example) the key lookup will be: "FCM_EMAIL_A"
  • In case of default the key lookup will be: "FCM_EMAIL"

this solution seems to not break current APIs.

Let me know your opinion and if is ok I'm going to update the readme.

@MihaelIsaev MihaelIsaev changed the base branch from master to multiple-clients June 14, 2024 09:43
@MihaelIsaev MihaelIsaev merged commit fa15dc2 into MihaelIsaev:multiple-clients Jun 14, 2024
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

Successfully merging this pull request may close these issues.

2 participants