Refactor getsvc #277
No reviewers
TrueCloudLab/storage-core-developers
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
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-node#277
Loading…
Reference in a new issue
No description provided.
Delete branch "dstepanov-yadro/frostfs-node:object-3606"
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?
The main goal: to make the GET service easier.
The first option is to divide the get service into three services: get, get range, head. But this approach will lead to code duplication. As a result, there will be three complex services.
So I refactored the GET service:
Also moved errors to separate files.
fcf8cf19a3
to3d58994f8a
WIP: Refactor getsvcto Refactor getsvc19bb559f4f
to88469f9859
@ -67,2 +20,2 @@
}
func New(
ks keyStorage,
Why this change? We use functional options in services and you can do everything with both?
For example, it was not obvious to me which of the dependencies and options were required and which were not.
So
New
requires mandatory deps,With...
- optional.Fixed back to Option for logger.
From https://github.com/uber-go/guide/blob/master/style.md#functional-options
Yes, but 5 positional arguments don't look nice either.
Not that I am against the change, but I if we were to commit to a new scheme, I would like to do this atomically across the whole repo. We can create an issue for the discussion.
I would prefer the positional arguments if they are required. They can be packed into a
Options
struct if needed.It seems relatively easy to build incorrect objects in other places as well, because of this.
I like struct, but it seems we do not enforce anything with it either.
However it may be easier to see what arguments are required.
We can try adopting this linter https://github.com/GaijinEntertainment/go-exhaustruct
Ofc it's not enforced, especially when having pointer fields. But I guess it's a combination of it being conventional and easier to look at the struct and its doc when calling
New
, rather than at the multiple option builders which might be spread around.how about a struct that shows a caller that it contains only the required params + validaion inside
New
(pointers to be sure it is not a default value)? i do not like 5 positional args tooWhat's the difference? Instead of 5 arguments, there will be a structure with 5 fields that will most likely be filled in when calling the
New
method.For example:
New
declaration: https://git.frostfs.info/TrueCloudLab/frostfs-node/src/branch/master/pkg/innerring/processors/frostfs/processor.go#L88New
call: https://git.frostfs.info/TrueCloudLab/frostfs-node/src/branch/master/pkg/innerring/initialization.go#L412But positional arguments have an advantage: if a new dependency is added to the
New
method, then with a very high probability the program will not assemble until this dependency is added everywhere.For me, it looks unreadable, especially when we provide a bunch of nil vars or empty strings.
It's about required arguments only. If you can pass nil or empty string as an argument value, i think that this argument is not required.
For not required arguments use Option.
88469f9859
tob9d557fbff
@ -109,3 +109,1 @@
w := NewSimpleObjectWriter()
prm.SetHeaderWriter(w)
err := exec.svc.Head(ctx, prm)
err := r.getDetached(ctx, p)
what does it mean? 1m was not enough for me to understand "detached" here
renamed
b9d557fbff
to0f73c7bb1b
0f73c7bb1b
to8de72f144d