control: use generics for response wrappers #290
No reviewers
Labels
No labels
P0
P1
P2
P3
badger
frostfs-adm
frostfs-cli
frostfs-ir
frostfs-lens
frostfs-node
good first issue
triage
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-node#290
Loading…
Reference in a new issue
No description provided.
Delete branch "fyrchik/frostfs-node:control-generics"
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?
a2f2dfd20a
to531f1cdc40
531f1cdc40
to83f31348d9
@ -28,3 +21,1 @@
w.m, ok = m.(*HealthCheckResponse)
if !ok {
return message.NewUnexpectedMessageType(m, w.m)
func newResponseWrapper[T any]() *responseWrapper[T] {
Maybe replace any -> grpc.Message? It looks strange if you don't look at
grpc.Message
definition.Fixed
83f31348d9
toe86c4ffd01
e86c4ffd01
tof73ac6e02d
@ -16,3 +16,2 @@
type healthCheckResponseWrapper struct {
m *HealthCheckResponse
type responseWrapper[T grpc.Message] struct {
this is kinda duped now:
type responseWrapper[M grpc.Message] struct {
let's move it to a common package and reuse it?
My rule of thumb is to abstract something when we have 3 occurences, we have 2 currently :)
The helper looks simple enough to tolerate some amount of duplication.
As you wish.
IMHO, abstracting it is trivial (move it to a separate package) and it's reasonable to expect that the abstraction will be used more than two places, since it serves to write many wrappers of the same type which are prevalent in the codebase. What's the benefit of tolerating the duplication anyway?
Could you elaborate how you came to the constant 3 in your rule of thumb? I'm curious about the rationale behind it.
We will simplify the api-go itself in the near future, as @dstepanov-yadro noticed, these wrappers look like a kludge.