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

Create session package #8

Open
Anthony-Jhoiro opened this issue May 3, 2022 · 0 comments
Open

Create session package #8

Anthony-Jhoiro opened this issue May 3, 2022 · 0 comments
Labels
engine Affect the engine module

Comments

@Anthony-Jhoiro
Copy link
Contributor

Anthony-Jhoiro commented May 3, 2022

Session() will be the main function, it can be related to a "user".
It will be called by volume func and will execute Execute() func for each request in a group.

type Session struct {
All returned variables from a request
Global variables ? like token
}

func (s *Session) Create( rg Requestgroup) (error)

Add possibility to use "context" to pass variables (like token , or dataset)


Edit by Anthony-Jhoiro 03/05/2020

Interfaces suggestions (explanations bellow) :

package session

type Context interface {
	// ResolveVariable returns the value of a variable, if the variable does 
	// not exists in the context, return an empty string and false or return 
	// the value and true
	ResolveVariable(variableName string) (string, bool)
}

type SessionExecutionTrace struct {}

type Session interface {
	// Get the context of the session
	GetContext() Context
	// Run executes each step of the session
	Run() (SessionExecutionTrace, error)
}

// ContextBuilder Help to build contexts in an abstract way
type ContextBuilder interface {
	// AddVariable adds a variable to the context
	AddVariable(key string, value string)
	// ConcatContext adds the information of a context into the new context
	ConcatContext(ctx Context)
	// Build Build the context
	Build() Context
}

It is important that the SessionContext should be immutable as a lot of async processes might use it and we do not want to avoid side effects.To pass variables between Session "steps" a new context should be created each time.

To make this operation easier, a ContextBuilder can be useful to group all of our methods and help provide immutable contexts.

It might be a good idea to split the session package into 2 smaller packages to handle the main session and the context separately but might be overkill.

@Anthony-Jhoiro Anthony-Jhoiro added the engine Affect the engine module label Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engine Affect the engine module
Projects
None yet
Development

No branches or pull requests

1 participant