Skip to content
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

Streaming hoard #84

Merged
merged 3 commits into from
Dec 3, 2019
Merged

Streaming hoard #84

merged 3 commits into from
Dec 3, 2019

Conversation

silasdavis
Copy link
Collaborator

No description provided.

Signed-off-by: Silas Davis <silas@monax.io>
@silasdavis silasdavis force-pushed the streaming-hoard branch 9 times, most recently from e4d75b0 to 40282c5 Compare December 2, 2019 11:41
@silasdavis silasdavis changed the title WIP: Streaming hoard Streaming hoard Dec 2, 2019
@silasdavis silasdavis force-pushed the streaming-hoard branch 7 times, most recently from 52a8d8f to 87a97b9 Compare December 3, 2019 09:17
- Remove use of oneof - note this should be backwards compatible
- Update to version 7 and write changelog
- Code cleanup and refactor

Signed-off-by: Silas Davis <silas@monax.io>
Copy link
Contributor

@gregdhill gregdhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before tagging we need to do a version bump on all imports and in the go mod file. Without oneof, I question why we need to enforce message ordering server side. In the case of the salt (which is just another byte slice) why can't we simply append? Otherwise this looks good! Might be worth adding some documentation on using the js lib, but that is low priority.

streaming.go Outdated Show resolved Hide resolved
streaming.go Outdated
return fmt.Errorf("recevied multiple salts but there can be at most one")
}
if len(accum.Data) > 0 {
return fmt.Errorf("recevied salt after data but salt must come before all data chunks")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("recevied salt after data but salt must come before all data chunks")
return fmt.Errorf("received salt after data but salt must come before all data chunks")

if chunk == nil {
return nil
}
if len(chunk.Salt) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to enforce these constraints on the salt?

document.go Outdated
@@ -7,12 +7,12 @@ import (
"fmt"

"github.com/gogo/protobuf/proto"
"github.com/monax/hoard/v6/api"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all hoard imports should point to v7 now...

@@ -2,32 +2,28 @@ module github.com/monax/hoard/v6

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should point to v7.

streaming.go Outdated
"fmt"
"io"

"github.com/monax/hoard/v6/api"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v++

streaming.go Outdated

if d.Meta != nil {
if accum.Meta != nil {
return nil, fmt.Errorf("recevied multiple document meta but there can be at most one")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil, fmt.Errorf("recevied multiple document meta but there can be at most one")
return nil, fmt.Errorf("received multiple document meta but there can be at most one")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can we only consume one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we add two - which one is the real one?

Or are you consider we allow them to be composited - this seems like an unnecessary complication. Almost by definition we don't expect our metadata to be so large - much better if we can be sure once we have read the metadata we have all of it.

streaming.go Outdated Show resolved Hide resolved
streaming.go Outdated
return fmt.Errorf("recevied multiple grant specs but there can be at most one")
}
if len(accum.Plaintext.Data) > 0 {
return fmt.Errorf("recevied grant spec after data but spec must come before all data chunks")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("recevied grant spec after data but spec must come before all data chunks")
return fmt.Errorf("received grant spec after data but spec must come before all data chunks")

"io"
"testing"

"github.com/monax/hoard/v6/api"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v++

@silasdavis
Copy link
Collaborator Author

Without oneof, I question why we need to enforce message ordering server side. In the case of the salt (which is just another byte slice) why can't we simply append?

The primary reason is that we want to be able to read the beginning of a stream sequentially and get the metadata without reading further in. If we allow out-of-order transmission then either we need to re-order it which is a pain or we loose the ability to take the HEAD of a stream and extract the metadata.

We could append on the salt but again we provide flexibility but there is no good reason to split up a salt - it is probably a mistake.

Generally having stronger invariants is better than have more arbitrary flexibility if it is not clear what good that does. We basically have some descriptive metadata and some stream. If it wasn't for the way plaintexts are handled I'd be tempted to have a message like:

message Document {
   Metadata Data = 1;
   bytes Data = 2;
}

And include the salt, metadata, grantspec and whatever other stuff you are only meant to say once in there. We could still go this route but I didn't want to make too many changes.

Might be worth adding some documentation on using the js lib, but that is low priority.
I have put a far few comments in the code - I'm not sure I want to maintain more detached documentation at this point...

Signed-off-by: Silas Davis <silas@monax.io>
@gregdhill gregdhill merged commit 92dad7c into monax:master Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants