Class Session
Namespace: Consul
Assembly: Consul.dll
Session can be used to query the Session endpoints
public class Session : ISessionEndpoint
Inheritance
Implements
Inherited Members
object.Equals(object) , object.Equals(object, object) , object.GetHashCode() , object.GetType() , object.MemberwiseClone() , object.ReferenceEquals(object, object) , object.ToString()
Methods
Create(CancellationToken)
Create makes a new session. Providing a session entry can customize the session. It can also be null to use defaults.
public Task<WriteResult<string>> Create(CancellationToken ct = default)
Parameters
The cancellation token
Returns
Task <WriteResult <string >>
A write result containing the new session ID
Create(SessionEntry, CancellationToken)
Create makes a new session with default options.
public Task<WriteResult<string>> Create(SessionEntry se, CancellationToken ct = default)
Parameters
se
SessionEntry
Returns
Task <WriteResult <string >>
A write result containing the new session ID
Create(SessionEntry, WriteOptions, CancellationToken)
Create makes a new session. Providing a session entry can customize the session. It can also be null to use defaults.
public Task<WriteResult<string>> Create(SessionEntry se, WriteOptions q, CancellationToken ct = default)
Parameters
se
SessionEntry
The SessionEntry options to use
Customized write options
The cancellation token
Returns
Task <WriteResult <string >>
A write result containing the new session ID
CreateNoChecks(CancellationToken)
CreateNoChecks is like Create but is used specifically to create a session with no associated health checks.
public Task<WriteResult<string>> CreateNoChecks(CancellationToken ct = default)
Parameters
Returns
Task <WriteResult <string >>
CreateNoChecks(SessionEntry, CancellationToken)
CreateNoChecks is like Create but is used specifically to create a session with no associated health checks.
public Task<WriteResult<string>> CreateNoChecks(SessionEntry se, CancellationToken ct = default)
Parameters
se
SessionEntry
The SessionEntry options to use
The cancellation token
Returns
Task <WriteResult <string >>
A write result containing the new session ID
CreateNoChecks(SessionEntry, WriteOptions, CancellationToken)
CreateNoChecks is like Create but is used specifically to create a session with no associated health checks.
public Task<WriteResult<string>> CreateNoChecks(SessionEntry se, WriteOptions q, CancellationToken ct = default)
Parameters
se
SessionEntry
The SessionEntry options to use
Customized write options
The cancellation token
Returns
Task <WriteResult <string >>
A write result containing the new session ID
Destroy(string, CancellationToken)
Destroy invalidates a given session
public Task<WriteResult<bool>> Destroy(string id, CancellationToken ct = default)
Parameters
id
string
The session ID to destroy
The cancellation token
Returns
Task <WriteResult <bool >>
A write result containing the result of the session destruction
Destroy(string, WriteOptions, CancellationToken)
Destroy invalidates a given session
public Task<WriteResult<bool>> Destroy(string id, WriteOptions q, CancellationToken ct = default)
Parameters
id
string
The session ID to destroy
Customized write options
The cancellation token
Returns
Task <WriteResult <bool >>
A write result containing the result of the session destruction
Info(string, CancellationToken)
Info looks up a single session
public Task<QueryResult<SessionEntry>> Info(string id, CancellationToken ct = default)
Parameters
id
string
The session ID to look up
The cancellation token
Returns
Task <QueryResult <SessionEntry >>
A query result containing the session information, or an empty query result if the session entry does not exist
Info(string, QueryOptions, CancellationToken)
Info looks up a single session
public Task<QueryResult<SessionEntry>> Info(string id, QueryOptions q, CancellationToken ct = default)
Parameters
id
string
The session ID to look up
Customized query options
The cancellation token
Returns
Task <QueryResult <SessionEntry >>
A query result containing the session information, or an empty query result if the session entry does not exist
List(CancellationToken)
List gets all active sessions
public Task<QueryResult<SessionEntry[]>> List(CancellationToken ct = default)
Parameters
Returns
Task <QueryResult <SessionEntry []>>
A query result containing list of all sessions, or an empty query result if no sessions exist
List(QueryOptions, CancellationToken)
List gets all active sessions
public Task<QueryResult<SessionEntry[]>> List(QueryOptions q, CancellationToken ct = default)
Parameters
Customized query options
The cancellation token
Returns
Task <QueryResult <SessionEntry []>>
A query result containing the list of sessions, or an empty query result if no sessions exist
Node(string, CancellationToken)
Node gets all sessions for a node
public Task<QueryResult<SessionEntry[]>> Node(string node, CancellationToken ct = default)
Parameters
node
string
The node ID
The cancellation token
Returns
Task <QueryResult <SessionEntry []>>
A query result containing the list of sessions, or an empty query result if no sessions exist
Node(string, QueryOptions, CancellationToken)
Node gets all sessions for a node
public Task<QueryResult<SessionEntry[]>> Node(string node, QueryOptions q, CancellationToken ct = default)
Parameters
node
string
The node ID
Customized query options
The cancellation token
Returns
Task <QueryResult <SessionEntry []>>
A query result containing the list of sessions, or an empty query result if no sessions exist
Renew(string, CancellationToken)
Renew renews the TTL on a given session
public Task<WriteResult<SessionEntry>> Renew(string id, CancellationToken ct = default)
Parameters
id
string
The session ID to renew
The cancellation token
Returns
Task <WriteResult <SessionEntry >>
An updated session entry
Renew(string, WriteOptions, CancellationToken)
Renew renews the TTL on a given session
public Task<WriteResult<SessionEntry>> Renew(string id, WriteOptions q, CancellationToken ct = default)
Parameters
id
string
The session ID to renew
Customized write options
The cancellation token
Returns
Task <WriteResult <SessionEntry >>
An updated session entry
RenewPeriodic(TimeSpan, string, CancellationToken)
RenewPeriodic is used to periodically invoke Session.Renew on a session until a CancellationToken is cancelled. This is meant to be used in a long running call to ensure a session stays valid until completed.
public Task RenewPeriodic(TimeSpan initialTTL, string id, CancellationToken ct)
Parameters
initialTTL
TimeSpan
The initital TTL to renew for
id
string
The session ID to renew
The CancellationToken used to stop the session from being renewed (e.g. when the long-running action completes)
Returns
RenewPeriodic(TimeSpan, string, WriteOptions, CancellationToken)
RenewPeriodic is used to periodically invoke Session.Renew on a session until a CancellationToken is cancelled. This is meant to be used in a long running call to ensure a session stays valid until completed.
public Task RenewPeriodic(TimeSpan initialTTL, string id, WriteOptions q, CancellationToken ct)
Parameters
initialTTL
TimeSpan
The initital TTL to renew for
id
string
The session ID to renew
Customized write options
The CancellationToken used to stop the session from being renewed (e.g. when the long-running action completes)