Panic in SDK functions #2
Labels
No labels
P0
P1
P2
P3
good first issue
pool
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-sdk-go#2
Loading…
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?
Currently we panic in many situations:
(netmap.NodeInfo).Price()
-- we expect to get it withFromV2
where an error is processed).While I think (1) is ok, others are not IMO. Also in (1) we could provide obligatory parameters explicitly: hard-to-misuse API is the best. Another option is to have
New
with obligatory parameters andSet
methods on it (private structure with public interface).@alexvanin @KirillovDenis @carpawell @realloc @acid-ant
I always thought that libraries should not panic in any "normal" cases. I think it is ok to have an exported error that says "i will not even try to make RPC call, u make stupid things" (for unset obligatory parameters, parameters that lead to dero division, etc) and allow a client to decide if he wants to panic. Otherwise, we force using
recover
if a client does not want his app to crash ever, which is not a true way ingo
.Here the only reason for
panic
is insufficiently expressive type system. If you use the code wrong, it is ok to panic, so I don't agree it is not a Go way. But I don't mind returning an error.We could panic if client init/dial parameter is invalid.
Let's not panic in the RPCs themselves.