mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2026-03-01 04:28:51 +00:00
Context-bound RPC requests #1133
Labels
No labels
I1
I2
I3
I4
S1
S2
S3
S4
U0
U1
U2
U3
U3
U4
blocked
bug
bug
cli
compiler
config
config
consensus
dependencies
discussion
documentation
enhancement
epic
feature
go
good first issue
help wanted
neotest
network
oracle
performance
question
rpc
security
smartcontract
task
task
task
test
vm
wallet
windows
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nspcc-dev/neo-go#1133
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @roman-khimov on GitHub (May 30, 2023).
We have a notion of client-wide
context.Context, but it's not very useful in most cases, contexts are more useful in per-request setting where they limit individual request processing time. Problems:net/httpprovides NewRequestWithContext for that, but we're not using it currentlyWSClientuses a library that doesn't have any notion of contexts (they can be emulated though, we're waiting on internal channels anyway)*Client.WithRequestContext(ctx) *Clientto be used for that purpose likesmth, err := c.WithRequestContext(ctx).GetApplicationLog(...)CC @smallhive, @notimetoname.
@notimetoname commented on GitHub (May 30, 2023):
Some time ago one good guy opened my eyes and I started to see dirty code in a stored (nested inside structs)
context.Context; it was kinda obvious but I saw so many lines of code that do not follow that simple rule so I had not noticed that before. My life will never be the same. I would also add a linter (not a "classic" one but neither an article is) that checks and prevents it.IIRC, go devs admitted it is a mistake (for backward compatibility) and nothing can be done now.
Look weird to me. I would only go that way if I was sure I need to keep all the old code working.
@roman-khimov commented on GitHub (Jun 4, 2025):
The other option is to just provide a new client and deprecate the old one. They can share a lot of code internally yet the new API would be clearly different from the old one and everyone could migrate as needed.