コード例 #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
            });
        }
コード例 #2
0
ファイル: Lock.cs プロジェクト: shiliyuanma/HD.Configuration
        /// <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);
        }
コード例 #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);
        }
コード例 #4
0
ファイル: Session.cs プロジェクト: zz119/consuldotnet
        /// <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));
        }
コード例 #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));
        }
コード例 #6
0
ファイル: Session.cs プロジェクト: zz119/consuldotnet
 /// <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));
 }
コード例 #7
0
ファイル: Session.cs プロジェクト: zz119/consuldotnet
        /// <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));
        }
コード例 #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));
 }
コード例 #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));
 }