-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
2,846 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package rpcnames | ||
|
||
type Name int | ||
|
||
// TODO separate and reserve IDs forever | ||
|
||
const ( | ||
// Server | ||
|
||
Add Name = iota + 1 | ||
AddNS Name = iota + 1 | ||
Remove | ||
Set | ||
Handshake | ||
HandshakeAck | ||
Log | ||
Sync | ||
Get | ||
Bye | ||
|
||
// Client | ||
|
||
ClientSetClock | ||
ClientSendPayload | ||
) | ||
|
||
func (n Name) Encode() string { | ||
return string(rune(n)) | ||
} | ||
|
||
func (n Name) String() string { | ||
switch n { | ||
case Add: | ||
return "Add" | ||
case AddNS: | ||
return "AddNS" | ||
case Remove: | ||
return "Remove" | ||
case Set: | ||
return "Set" | ||
case Handshake: | ||
return "Handshake" | ||
case HandshakeAck: | ||
return "HandshakeAck" | ||
case Log: | ||
return "Log" | ||
case Sync: | ||
return "Sync" | ||
case Get: | ||
return "Get" | ||
case ClientSetClock: | ||
return "ClientSetClock" | ||
case ClientSendPayload: | ||
return "ClientSendPayload" | ||
case Bye: | ||
return "Close" | ||
} | ||
|
||
return "!UNKNOWN!" | ||
} | ||
|
||
func Decode(s string) Name { | ||
return Name(s[0]) | ||
} |
Oops, something went wrong.