Esempio n. 1
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 WriteResult <string> Create(SessionEntry se, WriteOptions q)
        {
            var res = _client.CreateWrite <SessionEntry, SessionCreationResult>("/v1/session/create", se, q).Execute();

            return(new WriteResult <string>()
            {
                RequestTime = res.RequestTime,
                Response = res.Response.ID
            });
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        /// <summary>
        /// CreateSession is used to create a new managed session
        /// </summary>
        /// <returns>The session ID</returns>
        private string CreateSession()
        {
            var se = new SessionEntry
            {
                Name = Opts.SessionName,
                TTL  = Opts.SessionTTL
            };

            return(_client.Session.Create(se).Response);
        }
Esempio n. 4
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));
        }
Esempio n. 5
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 WriteResult <string> CreateNoChecks(SessionEntry se, WriteOptions q)
        {
            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));
        }
Esempio n. 6
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));
 }
Esempio n. 7
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));
        }
Esempio n. 8
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)
 {
     return(CreateNoChecks(se, WriteOptions.Default));
 }
Esempio n. 9
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>
 /// <returns>A write result containing the new session ID</returns>
 public WriteResult <string> Create(SessionEntry se)
 {
     return(Create(se, WriteOptions.Empty));
 }