refactor: move http api to a new transport layer
This commit is contained in:
parent
476c4b056f
commit
0448f66ab2
41 changed files with 822 additions and 390 deletions
40
internal/transport/master/client.go
Normal file
40
internal/transport/master/client.go
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package master
|
||||
|
||||
import (
|
||||
"git.wzray.com/homelab/hivemind/internal/transport"
|
||||
"git.wzray.com/homelab/hivemind/internal/types"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
caller transport.Caller
|
||||
}
|
||||
|
||||
func New(caller transport.Caller) *Client {
|
||||
return &Client{
|
||||
caller: caller,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) Heartbeat(endpoint string, n types.Node) (types.Nodes, error) {
|
||||
return heartbeatRoute.Call(c.caller, endpoint, n)
|
||||
}
|
||||
|
||||
func (c *Client) Join(endpoint string, n types.Node) (types.Nodes, error) {
|
||||
return joinRoute.Call(c.caller, endpoint, n)
|
||||
}
|
||||
|
||||
func (c *Client) Leave(endpoint string, n types.Node) error {
|
||||
return leaveRoute.CallNoOutput(c.caller, endpoint, n)
|
||||
}
|
||||
|
||||
func (c *Client) EventHeartbeat(endpoint string, n types.Node) (types.Nodes, error) {
|
||||
return eventHeartbeatRoute.Call(c.caller, endpoint, n)
|
||||
}
|
||||
|
||||
func (c *Client) EventJoin(endpoint string, n types.Node) (types.Nodes, error) {
|
||||
return eventJoinRoute.Call(c.caller, endpoint, n)
|
||||
}
|
||||
|
||||
func (c *Client) EventLeave(endpoint string, n types.Node) error {
|
||||
return eventLeaveRoute.CallNoOutput(c.caller, endpoint, n)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue