You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, bitswap has a concept of "sessions" for related requests. However:
Using usually means reconstructing the storage stack starting at the exchange. I.e., make the session, create a new blockservice, wrap it in a dagservice, etc.
Sessions are hard to compose. We currently handle this by creating the session in the top-level command but it would be nice if commands could recursively "create" sessions kind of like a re-entrant mutex.
Sessions are specific to the exchange, even when we have multiple components that should all logically be associated with the session.
Proposal: Extract the session concept from bitswap and stash the session handle in the context. Ideally, sessions would be generic peer/request trackers that track how useful each connected peer is over the course of the session.
Pros:
We can share session information between subsystems.
We can pre-seed these sessions with additional information (e.g. providers) from the request.
Sessions become entirely implicit. We only need to care about them at the very top level where we decide that we're making an independent request.
Cons:
Will take some refactoring. We can make a simple version that just stashes a shared ID in the context and then slowly move from there.
Basic Interface:
// Begin begins a new session if there are no sessions associated with the context.funcBegin(ctx context.Context) (context.Context, context.CancelFunc) {}
// Leave dissociates the context with the current session.funcLeave(ctx context.Context) (context.Context) {}
// Fork forks off a new session, inheriting the state of the current session.// Ok, we can probably leave this till later...funcFork(ctx context.Context) (context.Context, context.CancelFunc) {}
// GetSession returns the session associated with this context, if any.funcGetSession(ctx context.Context) Session {}
typeSessioninterface {
funcAddPeer(piAddrInfo) // or maybe just a peer ID?// Eventually, this will contain other peer-management methods.
}
Currently, bitswap has a concept of "sessions" for related requests. However:
Proposal: Extract the session concept from bitswap and stash the session handle in the context. Ideally, sessions would be generic peer/request trackers that track how useful each connected peer is over the course of the session.
Pros:
Cons:
Basic Interface:
Usage:
The text was updated successfully, but these errors were encountered: