mirror of https://github.com/hashicorp/consul
consul: Adding support for optional session name
parent
9a46a12fa5
commit
10f3007aa2
|
@ -34,6 +34,7 @@ func TestSessionCreate(t *testing.T) {
|
||||||
body := bytes.NewBuffer(nil)
|
body := bytes.NewBuffer(nil)
|
||||||
enc := json.NewEncoder(body)
|
enc := json.NewEncoder(body)
|
||||||
raw := map[string]interface{}{
|
raw := map[string]interface{}{
|
||||||
|
"Name": "my-cool-session",
|
||||||
"Node": srv.agent.config.NodeName,
|
"Node": srv.agent.config.NodeName,
|
||||||
"Checks": []string{consul.SerfCheckID, "consul"},
|
"Checks": []string{consul.SerfCheckID, "consul"},
|
||||||
"LockDelay": "20s",
|
"LockDelay": "20s",
|
||||||
|
|
|
@ -24,6 +24,7 @@ func TestSessionEndpoint_Apply(t *testing.T) {
|
||||||
Op: structs.SessionCreate,
|
Op: structs.SessionCreate,
|
||||||
Session: structs.Session{
|
Session: structs.Session{
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
|
Name: "my-session",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
var out string
|
var out string
|
||||||
|
@ -41,6 +42,12 @@ func TestSessionEndpoint_Apply(t *testing.T) {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
t.Fatalf("should not be 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
|
// Do a delete
|
||||||
arg.Op = structs.SessionDestroy
|
arg.Op = structs.SessionDestroy
|
||||||
|
|
|
@ -354,6 +354,7 @@ type IndexedKeyList struct {
|
||||||
type Session struct {
|
type Session struct {
|
||||||
CreateIndex uint64
|
CreateIndex uint64
|
||||||
ID string
|
ID string
|
||||||
|
Name string
|
||||||
Node string
|
Node string
|
||||||
Checks []string
|
Checks []string
|
||||||
LockDelay time.Duration
|
LockDelay time.Duration
|
||||||
|
|
|
@ -930,6 +930,7 @@ body must look like:
|
||||||
|
|
||||||
{
|
{
|
||||||
"LockDelay": "15s",
|
"LockDelay": "15s",
|
||||||
|
"Name": "my-service-lock",
|
||||||
"Node": "foobar",
|
"Node": "foobar",
|
||||||
"Checks": ["a", "b", "c"]
|
"Checks": ["a", "b", "c"]
|
||||||
}
|
}
|
||||||
|
@ -941,7 +942,8 @@ value. Small values are treated as seconds, and otherwise it is provided with
|
||||||
nanosecond granularity.
|
nanosecond granularity.
|
||||||
|
|
||||||
The `Node` field must refer to a node that is already registered. By default,
|
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.
|
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.
|
It is highly recommended that if you override this list, you include that check.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue