Git Product home page Git Product logo

Comments (5)

abatishchev avatar abatishchev commented on May 25, 2024 1

Hi @AliKhalili, thanks for reaching out and proposing an improve to the library!

Overall I don't mind and welcome it. Just needs some discussion first. I see two options:

  1. Change the interface to make all methods async

Pros:

  • only 1 method to call, no confusion

Cons:

  • 99,9..9% of scenarios are sync, this is the first every request to make it async. What adds a small but overhead, probably can be eased by leveraging a value task
  • a breaking change, constitutes bumping major version to 11.0
  1. Add a method to the interface

Pros:

  • tailored method signature to this scenario
  • isn't a breaking change, constitutes only minor version bump to 11.1

Cons:

  • introduces confusion (which method to call and when) and complexity (what would be the default implementation's behavior - wrap the sync result with a (value) task or throw an exception?)

What would be your take?

from jwt.

AliKhalili avatar AliKhalili commented on May 25, 2024

Hi @abatishchev,

Thank you for your response. I appreciate your openness to discussing this matter further.

While it is true that the majority of scenarios may be synchronous, it is becoming increasingly common for developers to expect asynchronous interfaces, especially in scenarios where cloud services(Cloud key management, Cloud HSM) are involved.

On the other hand, as you mentioned, the majority of the consumers are not expected to use the asynchronous methods, so it does not make sense to update the interface to make all methods asynchronous(in some cases it would be nearly impossible to change a legacy code base to be async and works without any problem).

Therefore, I would recommend providing both synchronous and asynchronous versions of each method. This allows consumers to choose which version they want to use based on their needs.
However, this approach can lead to code duplication and may make the interface more difficult to maintain.

from jwt.

abatishchev avatar abatishchev commented on May 25, 2024

Hi @AliKhalili,
I was sick past 2 months so couldn't come back to this.
You haven't followed up either. Is this something you're still interested in? If yes, can you contribute at least a draft of the proposed change?

from jwt.

AliKhalili avatar AliKhalili commented on May 25, 2024

Certainly, I hope you are feeling well.
Yes, I am interested in your request. Thank you for reaching out to me. Please allow me some time to work on it and I will be happy to provide you with a draft PR as soon as possible.

from jwt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.