示例#1
0
        protected static async Task DeleteAsync(string url)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = SimulacronManager.BaseAddress;
                var response = await client.DeleteAsync(url).ConfigureAwait(false);

                await SimulacronBase.EnsureSuccessStatusCode(response).ConfigureAwait(false);
            }
        }
示例#2
0
        protected static async Task <T> Get <T>(string url)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = SimulacronManager.BaseAddress;
                var response = await client.GetAsync(url).ConfigureAwait(false);

                await SimulacronBase.EnsureSuccessStatusCode(response).ConfigureAwait(false);

                var dataStr = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                return(JsonConvert.DeserializeObject <T>(dataStr));
            }
        }
示例#3
0
        protected static async Task <JObject> Post(string url, object body)
        {
            var bodyStr = SimulacronBase.GetJsonFromObject(body);
            var content = new StringContent(bodyStr, Encoding.UTF8, "application/json");

            using (var client = new HttpClient())
            {
                client.BaseAddress = SimulacronManager.BaseAddress;
                var response = await client.PostAsync(url, content).ConfigureAwait(false);

                await SimulacronBase.EnsureSuccessStatusCode(response).ConfigureAwait(false);

                var dataStr = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                return(JObject.Parse(dataStr));
            }
        }
示例#4
0
        public Task <JObject> PrimeFluentAsync(Func <IPrimeRequestBuilder, IThenFluent> builder)
        {
            var prime = SimulacronBase.PrimeBuilder();

            return(builder(prime).ApplyAsync(this));
        }
示例#5
0
 public Task PrimeDeleteAsync()
 {
     return(SimulacronBase.DeleteAsync(GetPath("prime")));
 }
示例#6
0
 public Task DisableConnectionListener(int attempts = 0, string type = "unbind")
 {
     return(SimulacronBase.DeleteAsync(GetPath("listener") + "?after=" + attempts + "&type=" + type));
 }
示例#7
0
 public dynamic GetConnections()
 {
     return(TaskHelper.WaitToComplete(SimulacronBase.Get <dynamic>(GetPath("connections"))));
 }
示例#8
0
 public Task <JObject> PrimeAsync(IPrimeRequest request)
 {
     return(SimulacronBase.Post(GetPath("prime"), request.Render()));
 }
示例#9
0
 public Task DropConnection(string ip, int port)
 {
     return(SimulacronBase.DeleteAsync(GetPath("connection") + "/" + ip + "/" + port));
 }
示例#10
0
 public Task PauseReadsAsync()
 {
     return(SimulacronBase.PutAsync(GetPath("pause-reads"), null));
 }
示例#11
0
 public Task ResumeReadsAsync()
 {
     return(SimulacronBase.DeleteAsync(GetPath("pause-reads")));
 }
示例#12
0
 public Task <JObject> EnableConnectionListener(int attempts = 0, string type = "unbind")
 {
     return(SimulacronBase.PutAsync(GetPath("listener") + "?after=" + attempts + "&type=" + type, null));
 }
示例#13
0
 public Task <dynamic> GetConnectionsAsync()
 {
     return(SimulacronBase.GetAsync <dynamic>(GetPath("connections")));
 }
示例#14
0
 public async Task RemoveAsync()
 {
     await SimulacronBase.DeleteAsync(GetPath("cluster")).ConfigureAwait(false);
 }
示例#15
0
 public Task Stop()
 {
     return(SimulacronBase.DeleteAsync($"/listener/{Id}?type=stop"));
 }
示例#16
0
 public Task <SimulacronClusterLogs> GetLogsAsync()
 {
     return(SimulacronBase.Get <SimulacronClusterLogs>(GetPath("log")));
 }
示例#17
0
 public Task Start()
 {
     return(SimulacronBase.PutAsync($"/listener/{Id}", null));
 }
示例#18
0
 protected Task <JObject> PostAsync(string url, object body)
 {
     return(SimulacronBase.PostAsync(_simulacronManager, url, body));
 }