Skip to main content

Class Session

Namespace: Consul
Assembly: Consul.dll

Session can be used to query the Session endpoints

public class Session : ISessionEndpoint

Inheritance

objectSession

Implements

ISessionEndpoint

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

ct CancellationToken

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

ct CancellationToken

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

q WriteOptions

Customized write options

ct CancellationToken

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

ct CancellationToken

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

ct CancellationToken

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

q WriteOptions

Customized write options

ct CancellationToken

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

ct CancellationToken

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

q WriteOptions

Customized write options

ct CancellationToken

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

ct CancellationToken

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

q QueryOptions

Customized query options

ct CancellationToken

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

ct CancellationToken

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

q QueryOptions

Customized query options

ct CancellationToken

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

ct CancellationToken

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

q QueryOptions

Customized query options

ct CancellationToken

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

ct CancellationToken

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

q WriteOptions

Customized write options

ct CancellationToken

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

ct CancellationToken

The CancellationToken used to stop the session from being renewed (e.g. when the long-running action completes)

Returns

Task

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

q WriteOptions

Customized write options

ct CancellationToken

The CancellationToken used to stop the session from being renewed (e.g. when the long-running action completes)

Returns

Task

  • Methods
    • Create(CancellationToken)
    • Create(SessionEntry, CancellationToken)
    • Create(SessionEntry, WriteOptions, CancellationToken)
    • CreateNoChecks(CancellationToken)
    • CreateNoChecks(SessionEntry, CancellationToken)
    • CreateNoChecks(SessionEntry, WriteOptions, CancellationToken)
    • Destroy(string, CancellationToken)
    • Destroy(string, WriteOptions, CancellationToken)
    • Info(string, CancellationToken)
    • Info(string, QueryOptions, CancellationToken)
    • List(CancellationToken)
    • List(QueryOptions, CancellationToken)
    • Node(string, CancellationToken)
    • Node(string, QueryOptions, CancellationToken)
    • Renew(string, CancellationToken)
    • Renew(string, WriteOptions, CancellationToken)
    • RenewPeriodic(TimeSpan, string, CancellationToken)
    • RenewPeriodic(TimeSpan, string, WriteOptions, CancellationToken)