consul: Adding support for optional session name
This commit is contained in:
parent
06cd40d1e7
commit
9e925bf458
|
@ -34,6 +34,7 @@ func TestSessionCreate(t *testing.T) {
|
|||
body := bytes.NewBuffer(nil)
|
||||
enc := json.NewEncoder(body)
|
||||
raw := map[string]interface{}{
|
||||
"Name": "my-cool-session",
|
||||
"Node": srv.agent.config.NodeName,
|
||||
"Checks": []string{consul.SerfCheckID, "consul"},
|
||||
"LockDelay": "20s",
|
||||
|
|
|
@ -24,6 +24,7 @@ func TestSessionEndpoint_Apply(t *testing.T) {
|
|||
Op: structs.SessionCreate,
|
||||
Session: structs.Session{
|
||||
Node: "foo",
|
||||
Name: "my-session",
|
||||
},
|
||||
}
|
||||
var out string
|
||||
|
@ -41,6 +42,12 @@ func TestSessionEndpoint_Apply(t *testing.T) {
|
|||
if s == nil {
|
||||
t.Fatalf("should not be nil")
|
||||
}
|
||||
if s.Node != "foo" {
|
||||
t.Fatalf("bad: %v", s)
|
||||
}
|
||||
if s.Name != "my-session" {
|
||||
t.Fatalf("bad: %v", s)
|
||||
}
|
||||
|
||||
// Do a delete
|
||||
arg.Op = structs.SessionDestroy
|
||||
|
|
|
@ -354,6 +354,7 @@ type IndexedKeyList struct {
|
|||
type Session struct {
|
||||
CreateIndex uint64
|
||||
ID string
|
||||
Name string
|
||||
Node string
|
||||
Checks []string
|
||||
LockDelay time.Duration
|
||||
|
|
|
@ -930,6 +930,7 @@ body must look like:
|
|||
|
||||
{
|
||||
"LockDelay": "15s",
|
||||
"Name": "my-service-lock",
|
||||
"Node": "foobar",
|
||||
"Checks": ["a", "b", "c"]
|
||||
}
|
||||
|
@ -941,7 +942,8 @@ value. Small values are treated as seconds, and otherwise it is provided with
|
|||
nanosecond granularity.
|
||||
|
||||
The `Node` field must refer to a node that is already registered. By default,
|
||||
the agent will use it's own name. Lastly, the `Checks` field is used to provide
|
||||
the agent will use it's own name. The `Name` field can be used to provide a human
|
||||
readable name for the Session. Lastly, the `Checks` field is used to provide
|
||||
a list of associated health checks. By default the "serfHealth" check is provided.
|
||||
It is highly recommended that if you override this list, you include that check.
|
||||
|
||||
|
|
Loading…
Reference in New Issue