mirror of
https://github.com/datarhei/core.git
synced 2025-11-03 10:30:53 +08:00
Refactor cluster node code
This commit is contained in:
26
cluster/client/lock.go
Normal file
26
cluster/client/lock.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/datarhei/core/v16/encoding/json"
|
||||
)
|
||||
|
||||
func (c *APIClient) LockCreate(origin string, r LockRequest) error {
|
||||
data, err := json.Marshal(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = c.call(http.MethodPost, "/v1/lock", "application/json", bytes.NewReader(data), origin)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *APIClient) LockDelete(origin string, name string) error {
|
||||
_, err := c.call(http.MethodDelete, "/v1/lock/"+url.PathEscape(name), "application/json", nil, origin)
|
||||
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user