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

Example: increment-only counter #7

Merged
merged 1 commit into from
Feb 2, 2016
Merged

Example: increment-only counter #7

merged 1 commit into from
Feb 2, 2016

Conversation

peterbourgon
Copy link
Contributor

An increment-only counter shared among peers, as a strawman to test and improve upon the user-facing API.

Suggested action items from this experiment:

  • Rename mesh.Config to mesh.RouterConfig.
  • Modify mesh.NewRouter to place mesh.RouterConfig last, and ensure sensible defaults if fields aren't specified.
  • Create simplified mesh.NewSimpleRouter constructor, with fewer options.
  • As a user, I have no way of knowing what type of string I should pass to PeerNameFrom{String,UserInput}, except a priori. So, I propose to remove non-MAC-based PeerName, and amend MAC PeerName documentation to make it clear it's not strictly necessary to use a MAC address.
  • Move InitializeConnections to the Router object directly, so we can eliminate connectionMaker from the exported API
  • In the router, port should be a string, just as everywhere else in the standard library.
  • Improve documentation and provide examples of what is an Overlay and why I should care. (Will investigate this in the next example.)
  • mesh should use a passed logger rather than the global logger

@peterbourgon peterbourgon force-pushed the simple-example branch 2 times, most recently from c6e3bd2 to 116a01b Compare February 1, 2016 19:41
@rade
Copy link
Member

rade commented Feb 2, 2016

Remove non-MAC-based PeerName, and amend MAC PeerName documentation to make it clear it's not strictly necessary to use a MAC address

But if MAC PeerName is the only one supported, then how would one "not use a MAC address"?

@peterbourgon
Copy link
Contributor Author

The problem is that users have a choice that's conditional on a build flag, which no one will use. Perhaps we can strictly type PeerName string and provide multiple constructors,

  • func NewHardwareAddrPeerName(hwAddr string) PeerName
  • func NewHexPeerName(hex string) PeerName
  • func NewHashablePeerName(userInput string) PeerName
  • func NewBytesPeerName(buf []byte) PeerName

@rade
Copy link
Member

rade commented Feb 2, 2016

That won't work. The choice of peer name representation is a build time flag for a reason: it affects the protocol and therefore has to be the same on all weave peers.

@peterbourgon peterbourgon changed the title [WIP] Simple example Simple example Feb 2, 2016
@peterbourgon peterbourgon changed the title Simple example Example: increment-only counter Feb 2, 2016
peterbourgon added a commit that referenced this pull request Feb 2, 2016
Example: increment-only counter
@peterbourgon peterbourgon merged commit 1e75599 into master Feb 2, 2016
@peterbourgon peterbourgon deleted the simple-example branch February 2, 2016 11:02
# Increment-only counter

This example implements an in-memory key-value cache.
Keys are strings, and values are increment-only counters.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

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