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

Session ID - A ID to track execution between use cases #57

Open
jhomarolo opened this issue Dec 27, 2021 · 10 comments
Open

Session ID - A ID to track execution between use cases #57

jhomarolo opened this issue Dec 27, 2021 · 10 comments
Assignees
Labels
enhancement New feature or request hacktoberfest help wanted Extra attention is needed severity-minor Item is not urgent wip Work in progress

Comments

@jhomarolo
Copy link
Contributor

Is your feature request related to a problem? Please describe.
To improve the audit trail, the library should have an ID similar to the use case track id, but for a long track, between use cases.

Describe the solution you'd like
Implement a new ID called session ID that is created if is not exist (first run) and send through use cases by request. So when the audit trail executes, we should see a new ID there.

@jhomarolo jhomarolo added enhancement New feature or request ready-to-work Item is ready to work on it severity-minor Item is not urgent labels Dec 27, 2021
@VictorTBX
Copy link
Contributor

How would this be used since the auditTrail info is attached to an use case? From where could we get this data from?

Wouldn't this make more sense for rest and graphql glues?

@dalssoft
Copy link
Member

Having a code sample on how to use (not the implementation) the session ID would be a great start.

@jhomarolo jhomarolo added help wanted Extra attention is needed and removed ready-to-work Item is ready to work on it labels Dec 27, 2021
@jhomarolo
Copy link
Contributor Author

I imagine some changes that start inside this library, but that can expand to the entire ecosystem, mainly when it comes to passing the session ID, but for now, I imagine something internal to the application cycle itself (when a use case calls another use case).

Since we don't officially have a feature to explicitly use a use case as a step, I imagined creating a new parameter, not mandatory in the use case request. We can also discuss passing this information through context.

when run uc.auditTrail:

{
    type: 'use case',
    description: 'Add or Update an Item on a to-do List',
    sessionId:  '6545fb7f-f5dd-466a-b466-3330d1d48411',
    transactionId: '9985fb70-f56d-466a-b466-e200d1d4848c',
    elapsedTime: 1981800n, // in nanosecods
    user: { name: 'John', id: '923b8b9a', isAdmin: true },
    authorized: true,
    return: {
        Ok: { item: { id: 100, name: 'Do not forget this', position: 9 } }
    },
    steps: [  ]
}

Inside usecase.js, something like that:

this._auditTrail.transactionId = uuidv4()

        // audit trail
        this._auditTrail = this._mainStep._auditTrail
        this._auditTrail.type = this.type
        this._auditTrail.description = description
        this._auditTrail.transactionId = uuidv4()
        this._auditTrail.sessionId = body.sessionId ?? uuidv4()

or like that:

        //sessionId
        if(body.sessionId ){
            this._auditTrail.sessionId = body.sessionId 
            delete body.sessionId 
        } else {
            this._auditTrail.sessionId =  uuidv4()
        }

@jhomarolo jhomarolo added ready-to-work Item is ready to work on it wip Work in progress and removed ready-to-work Item is ready to work on it wip Work in progress labels Jan 15, 2022
@BritoDoug
Copy link
Contributor

I wanna take this issue, can you tag for me @jhomarolo ?

@jhomarolo jhomarolo added wip Work in progress and removed ready-to-work Item is ready to work on it labels Jan 15, 2022
@dalssoft
Copy link
Member

Having a code sample on how to use (not the implementation) the session ID would be a great start.

@jhomarolo the question was about the way to call it in a UC, not the implementation.

ex (not a suggestion, just what I would like to analyze):

const response = await usecase.run(request, sessionID)

One more thing: in order for a sessionID to be useful, it must be informed in the transport layer (REST, GraphQL, etc), since this information comes from outside the microservice / domain. Will sessionID have a special treatment for these layers?

@BritoDoug
Copy link
Contributor

@dalssoft I think in a two step work, first I'll implement a sessionID between UC, in another implementation, apply this in a transport layer

@italojs italojs closed this as completed May 4, 2022
@italojs italojs reopened this May 4, 2022
@dalssoft dalssoft moved this to More discussion is needed in Herbs - 3rd Anniversary Edition May 25, 2022
@BritoDoug
Copy link
Contributor

Sorry guys, I'll retake that!

@jhomarolo
Copy link
Contributor Author

Hi @BritoDoug any updates here?

@BritoDoug
Copy link
Contributor

Not yet @jhomarolo but I will send updates this week

@jhomarolo jhomarolo moved this to Ready to code in Herbs enterprise roadmap 2023 Jan 6, 2023
@jhomarolo jhomarolo moved this from Ready to code to In Progress in Herbs enterprise roadmap 2023 Jan 6, 2023
@jhomarolo
Copy link
Contributor Author

@BritoDoug do you still in this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest help wanted Extra attention is needed severity-minor Item is not urgent wip Work in progress
Projects
Status: In Progress
Development

No branches or pull requests

5 participants