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

Add an example of a simple storage server #86

Merged
merged 15 commits into from
Jul 3, 2020

Conversation

johningve
Copy link
Member

@johningve johningve commented Jul 2, 2020

This PR adds an example storage server with a nice CLI to play with RPCs, quorum calls and configurations.

Currently depends on #81

asciicast

johningve added 2 commits July 3, 2020 07:27
This adds an example that provides a REPL-like experience for running
RPCs and quorum calls on different configurations.
@johningve johningve marked this pull request as ready for review July 3, 2020 07:48
@johningve johningve requested a review from meling July 3, 2020 07:48
johningve added 3 commits July 3, 2020 09:51
Gorums doesn't yet have stable releases, so it's probably safest to avoid
updating any modules
The github.com/chzyer/readline package appears to be abandoned.
Looking at the pprof command in go, I found a suitable alternative from
the crypto module.

## Prerequisites

Requires Go 1.13 or later and you must have `$GOPATH/bin` in your `$PATH`.
Copy link
Member

Choose a reason for hiding this comment

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

We don’t want to refer to GOPATH. Suggest we just remove this, unless we actually depend on paths; if we do we could explain that we use GOBIN as a reference for where our go binaries are saved.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's still relevant to use GOPATH here though. That way you can simply run go get github.com/relab/gorums/examples/storage. And then the storage binary will be available. I've always thought of GOPATH/bin as the "default", and GOBIN as an override.

Copy link
Member

Choose a reason for hiding this comment

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

ok. Maybe we can just link to the official instructions, to avoid being specific about GOPATH. They also use this:

$ go get golang.org/x/tour
This will place the tour binary in your workspace's bin directory.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

"the GOPATH environment variable specifies the location of your workspace"

@johningve
Copy link
Member Author

@meling I found two alternatives for implementing a readline-style CLI:

  1. github.com/chzyer/readline
  2. golang.org/x/crypto/ssh/terminal

The first one has a much larger feature set, but the project seems to be abandoned. It is still, however, used by google/pprof. It also has some minor issues on windows

The second one has the basic features we need, but struggles with arrow keys on windows for some reason. This package is used by the pprof tool shipped by Go. Additionally, it looks like this package is moving to golang.org/x/term in the future.

We could also try using the github.com/containerd/console package as suggested on stackoverflow

For now option 2 is implemented, and it works on windows except for arrow keys.

@meling
Copy link
Member

meling commented Jul 3, 2020

@meling I found two alternatives for implementing a readline-style CLI:

  1. github.com/chzyer/readline
  2. golang.org/x/crypto/ssh/terminal

The first one has a much larger feature set, but the project seems to be abandoned. It is still, however, used by google/pprof. It also has some minor issues on windows

The second one has the basic features we need, but struggles with arrow keys on windows for some reason. This package is used by the pprof tool shipped by Go. Additionally, it looks like this package is moving to golang.org/x/term in the future.

We could also try using the github.com/containerd/console package as suggested on stackoverflow

For now option 2 is implemented, and it works on windows except for arrow keys.

I don't have a strong preference, but it seems like going with the x/term version (to be) is a good option.

@johningve
Copy link
Member Author

Also, how do you feel about using a separate go.mod for the examples? VSCode still has a problem with it, but it can be worked around by creating a multi-root workspace.

The reason I wanted to have a separate module for the examples, was to try to make them separate from the gorums module, and preventing them from showing up in godoc, etc.

@meling
Copy link
Member

meling commented Jul 3, 2020

I actually prefer to use multiple modules for these things. But there are problems with VSCode; I find that with multi-root workspaces if you (accidentally) navigate into another module (from the top-level workspace) I get errors in files... Hopefully VSCode gets better at handling multi-root workspaces.

@meling meling merged commit d5f1873 into relab:master Jul 3, 2020
@johningve johningve deleted the repl-example branch July 6, 2020 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants