示例#1
0
        /// <summary>
        /// CreateSession is used to create a new managed session
        /// </summary>
        /// <returns>The session ID</returns>
        private async Task <string> CreateSession()
        {
            var se = new SessionEntry
            {
                Name = Opts.SessionName,
                TTL  = Opts.SessionTTL
            };

            return((await _client.Session.Create(se).ConfigureAwait(false)).Response);
        }
示例#2
0
        /// <summary>
        /// CreateNoChecks is like Create but is used specifically to create a session with no associated health checks.
        /// </summary>
        /// <param name="se">The SessionEntry options to use</param>
        /// <param name="q">Customized write options</param>
        /// <returns>A write result containing the new session ID</returns>
        public Task <WriteResult <string> > CreateNoChecks(SessionEntry se, WriteOptions q, CancellationToken ct = default(CancellationToken))
        {
            if (se == null)
            {
                return(Create(null, q));
            }
            var noChecksEntry = new SessionEntry()
            {
                Behavior  = se.Behavior,
                Checks    = new List <string>(0),
                LockDelay = se.LockDelay,
                Name      = se.Name,
                Node      = se.Node,
                TTL       = se.TTL
            };

            return(Create(noChecksEntry, q, ct));
        }
示例#3
0
 /// <summary>
 /// CreateNoChecks is like Create but is used specifically to create a session with no associated health checks.
 /// </summary>
 /// <param name="se">The SessionEntry options to use</param>
 /// <returns>A write result containing the new session ID</returns>
 public Task <WriteResult <string> > CreateNoChecks(SessionEntry se, CancellationToken ct = default(CancellationToken))
 {
     return(CreateNoChecks(se, WriteOptions.Default, ct));
 }
示例#4
0
        /// <summary>
        /// Create makes a new session. Providing a session entry can customize the session. It can also be null to use defaults.
        /// </summary>
        /// <param name="se">The SessionEntry options to use</param>
        /// <param name="q">Customized write options</param>
        /// <returns>A write result containing the new session ID</returns>
        public async Task <WriteResult <string> > Create(SessionEntry se, WriteOptions q, CancellationToken ct = default(CancellationToken))
        {
            var res = await _client.Put <SessionEntry, SessionCreationResult>("/v1/session/create", se, q).Execute(ct).ConfigureAwait(false);

            return(new WriteResult <string>(res, res.Response.ID));
        }