public long _2_9_Qstat_Async(Disquuun disquuun) { WaitUntil("_2_9_Qstat_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var jobId = DisquuunDeserializer.AddJob(disquuun.AddJob(queueId, data_10).DEPRICATED_Sync()); var w = new Stopwatch(); w.Start(); var qstatLen = 0; disquuun.Qstat(queueId).Async( (command, data) => { qstatLen = DisquuunDeserializer.Qstat(data).len; w.Stop(); } ); WaitUntil("_2_9_Qstat_Async", () => (qstatLen == 1), 5); disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); return(w.ElapsedMilliseconds); }
public void _0_0_4_ReadmeSamplePipeline(Disquuun disquuun) { WaitUntil("_0_0_4_ReadmeSamplePipeline", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var fastacked = false; disquuun.Pipeline( disquuun.AddJob("my queue name", new byte[100]), disquuun.GetJob(new string[] { "my queue name" }) ).Execute( (command, data) => { if (command != DisqueCommand.GETJOB) { return; } var jobs = DisquuunDeserializer.GetJob(data); var jobIds = jobs.Select(jobData => jobData.jobId).ToArray(); var jobDatas = jobs.Select(jobData => jobData.jobData).ToList(); /* * fast ack all. */ disquuun.FastAck(jobIds).Async( (command2, data2) => { fastacked = true; } ); } ); WaitUntil("_0_0_4_ReadmeSamplePipeline", () => fastacked, 5); }
public long _2_8_Qlen_Async(Disquuun disquuun) { WaitUntil("_2_8_Qlen_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var jobId = DisquuunDeserializer.AddJob( disquuun.AddJob(queueId, data_10).DEPRICATED_Sync() ); var w = new Stopwatch(); w.Start(); var qlen = 0; disquuun.Qlen(queueId).Async( (c, data) => { qlen = DisquuunDeserializer.Qlen(data); w.Stop(); } ); WaitUntil("_2_8_Qlen_Async", () => (qlen == 1), 5); var result = disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); var ackCount = DisquuunDeserializer.FastAck(result); return(w.ElapsedMilliseconds); }
public long _2_0_1_AddJob_Async_TimeToLive(Disquuun disquuun) { WaitUntil("_2_0_1_AddJob_Async_TimeToLive", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var jobId = string.Empty; var w = new Stopwatch(); w.Start(); disquuun.AddJob(queueId, data_10, 0, "TTL", 100).Async( (command, result) => { jobId = DisquuunDeserializer.AddJob(result); w.Stop(); } ); WaitUntil("_2_0_1_AddJob_Async_TimeToLive", () => !string.IsNullOrEmpty(jobId), 5); // ack in. disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); return(w.ElapsedMilliseconds); }
public long _2_1_4_GetJobWithCounters_Async(Disquuun disquuun) { WaitUntil("_2_1_4_GetJobWithCounters_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); disquuun.AddJob(queueId, data_100).DEPRICATED_Sync(); var ackCount = -1; var w = new Stopwatch(); w.Start(); disquuun.GetJob(new string[] { queueId }, "withcounters").Async( (command, result) => { var jobDatas = DisquuunDeserializer.GetJob(result); ackCount = jobDatas[0].additionalDeliveriesCount; w.Stop(); disquuun.FastAck(new string[] { jobDatas[0].jobId }).Async( (c, d) => { } ); } ); WaitUntil("_2_1_4_GetJobWithCounters_Async", () => (ackCount == 0), 5); return(w.ElapsedMilliseconds); }
public void _2_1_1_GetJobWithCount_Async(Disquuun disquuun) { WaitUntil("_2_1_1_GetJobWithCount_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var addJobCount = 10000; for (var i = 0; i < addJobCount; i++) { disquuun.AddJob(queueId, new byte[100]).DEPRICATED_Sync(); } DisquuunDeserializer.JobData[] jobDatas = new DisquuunDeserializer.JobData[] {}; disquuun.GetJob(new string[] { queueId }, "COUNT", addJobCount).Async( (command, result) => { jobDatas = DisquuunDeserializer.GetJob(result); } ); WaitUntil("_2_1_1_GetJobWithCount_Async", () => (jobDatas.Length == addJobCount), 5); // ack in. var jobIds = jobDatas.Select(job => job.jobId).ToArray(); disquuun.FastAck(jobIds).DEPRICATED_Sync(); }
public ConnectionServerTransformLayer(string contextQueueIdentity) { disquuun = new Disquuun( "127.0.0.1", 7711, 1024 * 100, 3, conId => { // enable adding job to Disque by swapping publisher method. context.Setup(Publish); // start getting job from disque then fastack all automatically. disquuun.GetJob(new string[] { contextQueueIdentity }, "count", 1000).Loop( (command, data) => { var jobs = DisquuunDeserializer.GetJob(data); var jobIds = jobs.Select(jobData => jobData.jobId).ToArray(); var jobDatas = jobs.Select(jobData => jobData.jobData).ToList(); /* * fast ack all. */ disquuun.FastAck(jobIds).Async((command2, data2) => {}); InputDatasToContext(jobDatas); return(true); } ); } ); }
public void _2_1_2_GetJobFromMultiQueue_Async(Disquuun disquuun) { WaitUntil("_2_1_2_GetJobFromMultiQueue_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId1 = Guid.NewGuid().ToString(); disquuun.AddJob(queueId1, new byte[10]).DEPRICATED_Sync(); var queueId2 = Guid.NewGuid().ToString(); disquuun.AddJob(queueId2, new byte[10]).DEPRICATED_Sync(); DisquuunDeserializer.JobData[] jobDatas = new DisquuunDeserializer.JobData[] {}; disquuun.GetJob(new string[] { queueId1, queueId2 }, "count", 2).Async( (command, result) => { jobDatas = DisquuunDeserializer.GetJob(result); } ); WaitUntil("_2_1_2_GetJobFromMultiQueue_Async", () => (jobDatas.Length == 2), 5); // ack in. var jobIds = jobDatas.Select(job => job.jobId).ToArray(); disquuun.FastAck(jobIds).DEPRICATED_Sync(); }
public long _2_1_GetJob_Async(Disquuun disquuun) { WaitUntil("_2_1_GetJob_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); disquuun.AddJob(queueId, data_10).DEPRICATED_Sync(); DisquuunDeserializer.JobData[] jobDatas = new DisquuunDeserializer.JobData[] { }; var w = new Stopwatch(); w.Start(); disquuun.GetJob(new string[] { queueId }).Async( (command, result) => { jobDatas = DisquuunDeserializer.GetJob(result); w.Stop(); } ); WaitUntil("_2_1_GetJob_Async", () => (jobDatas.Length == 1), 5); // ack in. var jobId = jobDatas[0].jobId; disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); return(w.ElapsedMilliseconds); }
public long _1_1_1_GetJobWithCount_Sync(Disquuun disquuun) { WaitUntil("_1_1_1_GetJobWithCount_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var w = new Stopwatch(); w.Start(); var queueId = Guid.NewGuid().ToString(); var addJobCount = 10000; for (var i = 0; i < addJobCount; i++) { disquuun.AddJob(queueId, data_100).DEPRICATED_Sync(); } var result = disquuun.GetJob(new string[] { queueId }, "COUNT", addJobCount).DEPRICATED_Sync(); var jobDatas = DisquuunDeserializer.GetJob(result); Assert("_1_1_1_GetJobWithCount_Sync", addJobCount, jobDatas.Length, "not match."); // ack in. var jobIds = jobDatas.Select(job => job.jobId).ToArray(); disquuun.FastAck(jobIds).DEPRICATED_Sync(); w.Stop(); return(w.ElapsedMilliseconds); }
public long _1_1_2_GetJobFromMultiQueue_Sync(Disquuun disquuun) { WaitUntil("_1_1_2_GetJobFromMultiQueue_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var w = new Stopwatch(); w.Start(); var queueId1 = Guid.NewGuid().ToString(); disquuun.AddJob(queueId1, data_10).DEPRICATED_Sync(); var queueId2 = Guid.NewGuid().ToString(); disquuun.AddJob(queueId2, data_10).DEPRICATED_Sync(); var result = disquuun.GetJob(new string[] { queueId1, queueId2 }, "count", 2).DEPRICATED_Sync(); var jobDatas = DisquuunDeserializer.GetJob(result); Assert("_1_1_2_GetJobFromMultiQueue_Sync", 2, jobDatas.Length, "not match."); // ack in. var jobIds = jobDatas.Select(job => job.jobId).ToArray(); disquuun.FastAck(jobIds).DEPRICATED_Sync(); w.Stop(); return(w.ElapsedMilliseconds); }
public void _0_0_2_ReadmeSampleSync(Disquuun disquuun) { bool overed = false; disquuun = new Disquuun(DisquuunTests.TestDisqueHostStr, DisquuunTests.TestDisquePortNum, 1024, 1, disquuunId => { var queueId = Guid.NewGuid().ToString(); // addjob. add 10bytes job to Disque. disquuun.AddJob(queueId, new byte[10]).DEPRICATED_Sync(); // getjob. get job from Disque. var result = disquuun.GetJob(new string[] { queueId }).DEPRICATED_Sync(); var jobDatas = DisquuunDeserializer.GetJob(result); Assert("_0_0_2_ReadmeSampleSync", 1, jobDatas.Length, "not match."); // fastack. var jobId = jobDatas[0].jobId; disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); overed = true; } ); WaitUntil("", () => overed, 5); disquuun.Disconnect(); }
public long _4_5_ByfferOverWithSokcetOverSyncGetJob_Async(Disquuun disquuun) { WaitUntil("_4_5_ByfferOverWithSokcetOverSyncGetJob_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var addJobCount = 10001; for (var i = 0; i < addJobCount; i++) { disquuun.AddJob(queueId, data_100).DEPRICATED_Sync(); } DisquuunDeserializer.JobData[] jobDatas = new DisquuunDeserializer.JobData[] { }; disquuun.GetJob(new string[] { queueId }, "COUNT", addJobCount).Async( (command, result) => { jobDatas = DisquuunDeserializer.GetJob(result); } ); WaitUntil("_4_5_ByfferOverWithSokcetOverSyncGetJob_Async", () => (jobDatas.Length == addJobCount), 5); // ack in. var jobIds = jobDatas.Select(job => job.jobId).ToArray(); disquuun.FastAck(jobIds).DEPRICATED_Sync(); return(0); }
public long _0_0_3_ReadmeSampleAsync(Disquuun disquuun) { var w = new Stopwatch(); w.Start(); int fastAckedJobCount = 0; disquuun = new Disquuun(DisquuunTests.TestDisqueHostStr, DisquuunTests.TestDisquePortNum, 1024, 3, disquuunId => { var queueId = Guid.NewGuid().ToString(); // addjob. add 10bytes job to Disque. disquuun.AddJob(queueId, data_10).Async( (addJobCommand, addJobData) => { // job added to queueId @ Disque. // getjob. get job from Disque. disquuun.GetJob(new string[] { queueId }).Async( (getJobCommand, getJobData) => { // got job from queueId @ Disque. var jobDatas = DisquuunDeserializer.GetJob(getJobData); Assert("_0_0_3_ReadmeSampleAsync", 1, jobDatas.Length, "not match."); // get jobId from got job data. var gotJobId = jobDatas[0].jobId; // fastack it. disquuun.FastAck(new string[] { gotJobId }).Async( (fastAckCommand, fastAckData) => { // fastack succeded or not. fastAckedJobCount = DisquuunDeserializer.FastAck(fastAckData); Assert("_0_0_3_ReadmeSampleAsync", 1, fastAckedJobCount, "not match."); } ); } ); } ); }, (i, e) => { }, (currentSocketCount, addSocket) => { return; } ); WaitUntil("_0_0_3_ReadmeSampleAsync", () => (fastAckedJobCount == 1), 5); disquuun.Disconnect(); w.Stop(); return(w.ElapsedMilliseconds); }
public void _7_2_GetJob1000byLoop(Disquuun disquuun) { WaitUntil("_7_2_GetJob1000byLoop", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var addingJobCount = 1000 * loadLevel; var queueId = Guid.NewGuid().ToString(); var addedCount = 0; for (var i = 0; i < addingJobCount; i++) { disquuun.AddJob(queueId, new byte[10]).Async( (command, data) => { lock (_7_2_GetJob1000byLoopLockObject) addedCount++; } ); } WaitUntil("_7_2_GetJob1000byLoop", () => (addedCount == addingJobCount), 5); var gotJobDataIds = new List <string>(); var w = new Stopwatch(); w.Start(); disquuun.GetJob(new string[] { queueId }).Loop( (command, data) => { lock (_7_2_GetJob1000byLoopLockObject) { var jobDatas = DisquuunDeserializer.GetJob(data); var jobIds = jobDatas.Select(j => j.jobId).ToList(); gotJobDataIds.AddRange(jobIds); if (gotJobDataIds.Count == addingJobCount) { w.Stop(); return(false); } return(true); } } ); WaitUntil("_7_2_GetJob1000byLoop 1", () => (gotJobDataIds.Count == addingJobCount), 20); WaitUntil("_7_2_GetJob1000byLoop 2", () => (0 < disquuun.AvailableSocketNum()), 1); TestLogger.Log("_7_2_GetJob1000byLoop w:" + w.ElapsedMilliseconds + " tick:" + w.ElapsedTicks); var fastackedCount = 0; disquuun.FastAck(gotJobDataIds.ToArray()).Async( (c, data) => { fastackedCount = DisquuunDeserializer.FastAck(data); } ); WaitUntil("_7_2_GetJob1000byLoop 3", () => (addingJobCount == fastackedCount), 10); }
public long _3_0_Nested2AsyncSocket(Disquuun disquuun) { WaitUntil("_3_0_Nested2AsyncSocket", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var w = new Stopwatch(); w.Start(); var jobId1 = string.Empty; var queueId1 = Guid.NewGuid().ToString(); disquuun.AddJob(queueId1, data_10).Async( (command, data) => { jobId1 = DisquuunDeserializer.AddJob(data); } ); var jobId2 = string.Empty; var queueId2 = Guid.NewGuid().ToString(); disquuun.AddJob(queueId2, data_10).Async( (command, data) => { jobId2 = DisquuunDeserializer.AddJob(data); } ); WaitUntil("_3_0_Nested2AsyncSocket", () => (!string.IsNullOrEmpty(queueId1) && !string.IsNullOrEmpty(queueId2)), 5); w.Stop(); var done = false; disquuun.GetJob(new string[] { queueId1, queueId2 }, "count", 2).Async( (command, data) => { var gets = DisquuunDeserializer.GetJob(data); Assert("_3_0_Nested2AsyncSocket", 2, gets.Length, "not match."); disquuun.FastAck(gets.Select(job => job.jobId).ToArray()).Async( (c, d) => { done = true; } ); } ); WaitUntil("_3_0_Nested2AsyncSocket", () => done, 5); return(w.ElapsedMilliseconds); }
public long _9_1_LargeSizeSendThenSmallSizeSendLoopMakeEmitOnSendAfterOnReceived(Disquuun disquuun) { WaitUntil("_9_1_LargeSizeSendThenSmallSizeSendLoopMakeEmitOnSendAfterOnReceived", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var w = new Stopwatch(); w.Start(); for (var i = 0; i < 100; i++) { var queueId = Guid.NewGuid().ToString(); var index = 0; var bytes = new List <byte[]>(); bytes.Add(data_40000); bytes.Add(new byte[100]); disquuun.AddJob(queueId, bytes[index]).Loop( (command, data) => { index++; if (bytes.Count <= index) { return(false); } return(true); } ); WaitUntil("_9_1_LargeSizeSendThenSmallSizeSendLoopMakeEmitOnSendAfterOnReceived", () => (index == 2), 1); var fastacked = false; disquuun.GetJob(new string[] { queueId }, "count", 20).Async( (command, data) => { var jobDatas = DisquuunDeserializer.GetJob(data); var jobIds = jobDatas.Select(j => j.jobId).ToArray(); disquuun.FastAck(jobIds).Async( (command2, data2) => { fastacked = true; } ); } ); WaitUntil("_9_1_LargeSizeSendThenSmallSizeSendLoopMakeEmitOnSendAfterOnReceived", () => fastacked, 1); } w.Stop(); return(w.ElapsedMilliseconds); }
// all sync apis are deprecated. public void _1_0_AddJob_Sync(Disquuun disquuun) { WaitUntil("_1_0_AddJob_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var result = disquuun.AddJob(queueId, new byte[10]).DEPRICATED_Sync(); var jobId = DisquuunDeserializer.AddJob(result); Assert("_1_0_AddJob_Sync", !string.IsNullOrEmpty(jobId), "empty."); // ack in. disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); }
public void _0_9_2_MultipleCommandPipeline(Disquuun disquuun) { WaitUntil("_0_9_2_MultipleCommandPipeline", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var infoCount = 0; var addedJobId = string.Empty; var gotJobId = "_"; var queueId = Guid.NewGuid().ToString(); var jobData = new byte[100]; for (var i = 0; i < jobData.Length; i++) { jobData[i] = 1; } disquuun.Pipeline(disquuun.Info()); disquuun.Pipeline(disquuun.AddJob(queueId, jobData)); disquuun.Pipeline(disquuun.GetJob(new string[] { queueId })).Execute( (command, data) => { switch (command) { case DisqueCommand.INFO: { lock (_0_9_2_MultipleCommandPipelineObject) { infoCount++; } break; } case DisqueCommand.ADDJOB: { lock (_0_9_2_MultipleCommandPipelineObject) { addedJobId = DisquuunDeserializer.AddJob(data); } break; } case DisqueCommand.GETJOB: { lock (_0_9_2_MultipleCommandPipelineObject) { var gotJobDatas = DisquuunDeserializer.GetJob(data); gotJobId = gotJobDatas[0].jobId; disquuun.FastAck(new string[] { gotJobId }).DEPRICATED_Sync(); } break; } } } ); WaitUntil("_0_9_2_MultipleCommandPipeline", () => (infoCount == 1 && !string.IsNullOrEmpty(addedJobId) && gotJobId == addedJobId), 5); }
public void _1_3_Fastack_Sync(Disquuun disquuun) { WaitUntil("_1_3_Fastack_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var jobId = DisquuunDeserializer.AddJob( disquuun.AddJob(queueId, new byte[10]).DEPRICATED_Sync() ); var result = disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); var ackCount = DisquuunDeserializer.FastAck(result); Assert("_1_3_Fastack_Sync", 1, ackCount, "not match."); }
public long _3_1_NestedMultipleAsyncSocket(Disquuun disquuun) { WaitUntil("_3_1_NestedMultipleAsyncSocket", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var addGetFastAckCount = 100; var resultCount = 0; var w = new Stopwatch(); w.Start(); for (var i = 0; i < addGetFastAckCount; i++) { disquuun.AddJob(queueId, data_10).Async( (c1, d1) => { Assert("_3_1_NestedMultipleAsyncSocket", DisqueCommand.ADDJOB, c1, "command mismatch."); disquuun.GetJob(new string[] { queueId }).Async( (c2, d2) => { Assert("_3_1_NestedMultipleAsyncSocket", DisqueCommand.GETJOB, c2, "command mismatch."); var gotJobs = DisquuunDeserializer.GetJob(d2); var gotJobId = gotJobs[0].jobId; var gotJobData = gotJobs[0].jobData; Assert("_3_1_NestedMultipleAsyncSocket", 10, gotJobData.Length, "not match."); disquuun.FastAck(new string[] { gotJobId }).Async( (c3, d3) => { Assert("_3_1_NestedMultipleAsyncSocket", DisqueCommand.FASTACK, c3, "command mismatch."); var fastackResult = DisquuunDeserializer.FastAck(d3); Assert("_3_1_NestedMultipleAsyncSocket", 1, fastackResult, "not match."); lock (_3_1_NestedMultipleAsyncSocketLockObject) resultCount++; w.Stop(); } ); } ); } ); } WaitUntil("_3_1_NestedMultipleAsyncSocket", () => (resultCount == addGetFastAckCount), 10); return(w.ElapsedMilliseconds); }
public void _1_9_Qstat_Sync(Disquuun disquuun) { WaitUntil("_1_9_Qstat_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var jobId = DisquuunDeserializer.AddJob( disquuun.AddJob(queueId, new byte[10]).DEPRICATED_Sync() ); var data = disquuun.Qstat(queueId).DEPRICATED_Sync(); var qstatData = DisquuunDeserializer.Qstat(data); Assert("_1_9_Qstat_Sync", 1, qstatData.len, "not match."); disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); }
public void _1_1_4_GetJobWithCounters_Sync(Disquuun disquuun) { WaitUntil("_1_1_4_GetJobWithCounters_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); disquuun.AddJob(queueId, new byte[100]).DEPRICATED_Sync(); var result = disquuun.GetJob(new string[] { queueId }, "withcounters").DEPRICATED_Sync(); var jobDatas = DisquuunDeserializer.GetJob(result); var ackCount = jobDatas[0].additionalDeliveriesCount; Assert("_1_1_4_GetJobWithCounters_Sync", 0, ackCount, "not match."); disquuun.FastAck(new string[] { jobDatas[0].jobId }).DEPRICATED_Sync(); }
public long _9_0_LargeSizeSendThenSmallSizeSendMakeEmitOnSendAfterOnReceived(Disquuun disquuun) { WaitUntil("_9_0_LargeSizeSendThenSmallSizeSendMakeEmitOnSendAfterOnReceived", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var w = new Stopwatch(); w.Start(); for (var i = 0; i < 100; i++) { var queueId = Guid.NewGuid().ToString(); var sended = false; disquuun.AddJob(queueId, data_40000).Async( (command, data) => { disquuun.AddJob(queueId, new byte[100]).Async( (command2, data2) => { sended = true; } ); } ); WaitUntil("_9_0_LargeSizeSendThenSmallSizeSendMakeEmitOnSendAfterOnReceived", () => (sended), 5); var fastacked = false; disquuun.GetJob(new string[] { queueId }, "count", 2).Async( (command, data) => { var jobDatas = DisquuunDeserializer.GetJob(data); var jobIds = jobDatas.Select(j => j.jobId).ToArray(); disquuun.FastAck(jobIds).Async( (command2, data2) => { fastacked = true; } ); } ); WaitUntil("_9_0_LargeSizeSendThenSmallSizeSendMakeEmitOnSendAfterOnReceived", () => fastacked, 5); } w.Stop(); return(w.ElapsedMilliseconds); }
public void _2_9_Qstat_Async(Disquuun disquuun) { WaitUntil("_2_9_Qstat_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var jobId = DisquuunDeserializer.AddJob(disquuun.AddJob(queueId, new byte[10]).DEPRICATED_Sync()); var qstatLen = 0; disquuun.Qstat(queueId).Async( (command, data) => { qstatLen = DisquuunDeserializer.Qstat(data).len; } ); WaitUntil("_2_9_Qstat_Async", () => (qstatLen == 1), 5); disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); }
public void _1_1_GetJob_Sync(Disquuun disquuun) { WaitUntil("_1_1_GetJob_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); disquuun.AddJob(queueId, new byte[10]).DEPRICATED_Sync(); var result = disquuun.GetJob(new string[] { queueId }).DEPRICATED_Sync(); var jobDatas = DisquuunDeserializer.GetJob(result); Assert("_1_1_GetJob_Sync", 1, jobDatas.Length, "not match."); // ack in. var jobId = jobDatas[0].jobId; disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); }
public void _4_0_ByfferOverWithSingleSyncGetJob_Sync(Disquuun disquuun) { WaitUntil("_4_0_ByfferOverWithSingleSyncGetJob_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); disquuun.AddJob(queueId, new byte[disquuun.bufferSize]).DEPRICATED_Sync(); var result = disquuun.GetJob(new string[] { queueId }).DEPRICATED_Sync(); var jobDatas = DisquuunDeserializer.GetJob(result); Assert("_4_0_ByfferOverWithSingleSyncGetJob_Sync", 1, jobDatas.Length, "not match."); // ack in. var jobIds = jobDatas.Select(job => job.jobId).ToArray(); disquuun.FastAck(jobIds).DEPRICATED_Sync(); }
public void _0_0_3_ReadmeSampleAsync(Disquuun disquuun) { int fastAckedJobCount = 0; disquuun = new Disquuun(DisquuunTests.TestDisqueHostStr, DisquuunTests.TestDisquePortNum, 1024, 3, disquuunId => { var queueId = Guid.NewGuid().ToString(); // addjob. add 10bytes job to Disque. disquuun.AddJob(queueId, new byte[10]).Async( (addJobCommand, addJobData) => { // job added to queueId @ Disque. // getjob. get job from Disque. disquuun.GetJob(new string[] { queueId }).Async( (getJobCommand, getJobData) => { // got job from queueId @ Disque. var jobDatas = DisquuunDeserializer.GetJob(getJobData); Assert("_0_0_3_ReadmeSampleAsync", 1, jobDatas.Length, "not match."); // get jobId from got job data. var gotJobId = jobDatas[0].jobId; // fastack it. disquuun.FastAck(new string[] { gotJobId }).Async( (fastAckCommand, fastAckData) => { // fastack succeded or not. fastAckedJobCount = DisquuunDeserializer.FastAck(fastAckData); Assert("_0_0_3_ReadmeSampleAsync", 1, fastAckedJobCount, "not match."); } ); } ); } ); } ); WaitUntil("_0_0_3_ReadmeSampleAsync", () => (fastAckedJobCount == 1), 5); disquuun.Disconnect(); }
public void _2_3_Fastack_Async(Disquuun disquuun) { WaitUntil("_2_3_Fastack_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var jobId = DisquuunDeserializer.AddJob( disquuun.AddJob(queueId, new byte[10]).DEPRICATED_Sync() ); var ackCount = 0; disquuun.FastAck(new string[] { jobId }).Async( (command, result) => { ackCount = DisquuunDeserializer.FastAck(result); } ); WaitUntil("_2_3_Fastack_Async", () => (ackCount == 1), 5); }
public void _2_0_AddJob_Async(Disquuun disquuun) { WaitUntil("_2_0_AddJob_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var jobId = string.Empty; disquuun.AddJob(queueId, new byte[10]).Async( (command, result) => { jobId = DisquuunDeserializer.AddJob(result); } ); WaitUntil("_2_0_AddJob_Async", () => !string.IsNullOrEmpty(jobId), 5); // ack in. disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); }