-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api, manifest: abstract saver/loader functionality #939
Conversation
pkg/manifest/manifest.go
Outdated
@@ -36,7 +35,7 @@ type Interface interface { | |||
// HasPrefix tests whether the specified prefix path exists. | |||
HasPrefix(string) (bool, error) | |||
// Store stores the manifest, returning the resulting address. | |||
Store(context.Context, storage.ModePut) (swarm.Address, error) | |||
Store() (swarm.Address, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the context.Context
should be left here.
pkg/file/io.go
Outdated
|
||
type Loader interface { | ||
// Load a reference in byte slice representation and return all content associated with the reference. | ||
Load([]byte) ([]byte, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is in Bee project, I think that Load
/Save
functions should return swarm.Address
directly.
And maybe allow passing context to both operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this interface was made to be compatible with manifest.Loader
in the manifest package. have a closer look that i am injecting this interface directly into the mantaray dependency on load and save. if you want it as an address then we need to change the interface in mantaray first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fully aware this was the reason. My comment is that we should not force external interface into this project.
The interface in "manatary" project was created to be independent from some external project. That interface is how it is, and should not be changed.
I would rather we have another level of indirection instead of having something like this. Especially since some other parts of Bee project might want to use this package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets revisit this when this is merged ethersphere/manifest#16
Compilation errors should be fixed https://github.com/ethersphere/bee/pull/939/checks?check_run_id=1390345361#step:7:9. |
@janos errors are intentional. waiting for viktor's PR to be merged to the manifest project |
@@ -107,3 +107,18 @@ func SplitWriteAll(ctx context.Context, s Splitter, r io.Reader, l int64, toEncr | |||
} | |||
return addr, nil | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these interfaces are defined twice. we should use only one and have it in storage
package maybe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these interfaces provide functionalities which are wrapping components in the file
package. that's why I put them here. it belongs here more than in storage
, which relates more to localstore
and the likes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only things I think should be changed is LoadSaver
function signatures, to use swarm.Address
. That way package may be usable for other things in the future.
|
||
type Loader interface { | ||
// Load a reference in byte slice representation and return all content associated with the reference. | ||
Load(context.Context, []byte) ([]byte, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think since we are in the bee
project, the Load
and Save
function should work directly with swarm.Address
, instead of using []byte
.
This may require having some proxy implementation for manifest, where we have implementation with byte slice, which translates to swarm.Address
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but then it means I need an extra abstraction that would use this one. I'm not sure why this is necessary. I only created this implementation to be compatible with the manta ray interfaces. I think that once other components need to use similar functionality we can generalize, but I'm not sure why to do so prematurely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I just do not think application should cater to library completely.
It can be seen that references are already used, but the simple
manifest implementation.
pkg/manifest/simple.go
Outdated
} | ||
|
||
// NewSimpleManifest creates a new simple manifest. | ||
func NewSimpleManifest( | ||
encrypted bool, | ||
storer storage.Storer, | ||
ls file.LoadSaver, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function signature may be collapsed now (it should be enough shorter).
this is needed so we don't need to pass
crypto.Signer
and batch IDs to the manifest package as part of the storage incentives effortneeded for #873