Skip to content

Commit

Permalink
feat(rpc): add pkg/rpc (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
pancsta authored Sep 11, 2024
1 parent d1c3aa4 commit 36297f3
Show file tree
Hide file tree
Showing 8 changed files with 2,846 additions and 0 deletions.
424 changes: 424 additions & 0 deletions pkg/rpc/client.go

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions pkg/rpc/rpcnames/rpcnames.go
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])
}
Loading

0 comments on commit 36297f3

Please sign in to comment.