Unify parameters in object services #495
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-node#495
Loading…
Reference in a new issue
No description provided.
Delete branch "dstepanov-yadro/frostfs-node:refactor/getsvc_unify_params"
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?
Now required dependencies are passed as args, other as options.
Closes #294
df939a090d
to842de037cc
842de037cc
to528bcc8f42
528bcc8f42
to1c79835600
1c79835600
to08c4e219f0
WIP: Unify parameters in object servicesto Unify parameters in object services@ -38,3 +37,1 @@
func (c *CheckerPrm) SetValidator(v *eaclSDK.Validator) *CheckerPrm {
c.validator = v
return c
type localStorage struct {
why the
struct
even? just alias it?From here: #495/files
@ -46,1 +41,3 @@
}
func (s *localStorage) Head(ctx context.Context, addr oid.Address) (*objectSDK.Object, error) {
if s.ls == nil {
return nil, io.ErrUnexpectedEOF
this might hide a more serious error, no? (i.e. a missing/nil argument somewhere)
again from here: #495/files#diff-65b4b70b0453f2a0abd08c354212feeb6a6680d4
@ -75,0 +72,4 @@
opts ...Option) *Service {
c := &cfg{
log: &logger.Logger{Logger: zap.L()},
header: (*headSvcWrapper)(gs),
do we plan to get rid of these casts that scare adults and children alike in another task/PR?
fixed
@ -84,0 +80,4 @@
cs container.Source,
opts ...Option) Service {
cfg := &cfg{
log: &logger.Logger{Logger: zap.L()},
I think that
New
should havelog log.Logger
parameter that can be used forcfg
instance creation. This will support dependency inversion.From the other side - this barely can be helpful because we do not use mocks
logger
can be passed with options, because logger is not mandatory and default logger will be used if it is not proovided@ -63,0 +62,4 @@
nk netmap.AnnouncedKeys,
nst netmap.State,
opts ...Option) *Service {
c := &cfg{
Here are inevitably many mandatory parameters. Don't you consider to unite some parameters in one struct?
Just for example
Let's assume that you decided to add a new dependency. If you use a structure with fields, as you suggested, then you can easily forget to initialize one of the fields, and discover it only during execution.
In the case of passing by argument, the source code simply will not be assembled until you pass a new dependency.
Another possibility is having a linter which can check whether all struct fields are filled? Like this:
This linter must be smart enough to find all
if/else
branches.Well, we could enforce providing all values immediately and move all if/else branches above.
But obviously needs discussion first.
08c4e219f0
to0f348270da
For commit messages we had
services/put
, thenputsvc
(initiated by you, I believe #277/commits ) and nowput service
. Can we stay withputsvc
,aclsvc
etc.?TestEvacuateShard
is flaky #3820f348270da
to35ecdf062d
Done
@ -85,0 +80,4 @@
acl ACLChecker,
cs container.Source,
opts ...Option) Service {
cfg := &cfg{
Can we remove
panicOnNil
below?done
35ecdf062d
tobb832702e3