static void Main(string[] args) { var client = new GearmanClient(); var host = "smeagol"; client.AddServer(host, 4730); client.AddServer(host, 4731); CreateBackgroundJobs(client, 10); //CreateJobs(client, 100); }
public void AdvancedClient() { var client = new GearmanClient(); client.AddServer("gearman.example.com"); client.AddServer("10.0.0.2", 4730); var urls = new List<string> { "http://www.youtube.com/watch?v=abc123456", "http://www.youtube.com/watch?v=xyz9876" }; var oembeds = client.SubmitJob<IList<string>, IList<OEmbed>>("GetOEmbeds", urls, Serializers.JsonSerialize<IList<string>>, Serializers.JsonDeserialize<IList<OEmbed>>); }
public void can_submit_backgroundjob() { var client = new GearmanClient(); client.AddServer(Helpers.TestServerHost, Helpers.TestServerPort); var jobRequest = client.SubmitBackgroundJob("reverse", Encoding.ASCII.GetBytes("Hello World")); Assert.IsNotNull(jobRequest); Assert.IsNotNull(jobRequest.JobHandle); }
public void can_fetch_jobstatus() { var client = new GearmanClient(); client.AddServer(Helpers.TestServerHost, Helpers.TestServerPort); var jobRequest = client.SubmitBackgroundJob("reverse", Encoding.ASCII.GetBytes("Hello World")); var jobStatus = client.GetStatus(jobRequest); Assert.IsNotNull(jobStatus); // We can't safely assert that jobStatus.IsKnown is true, but it most likely should be. }
public void can_get_job_event() { bool createFired = false; bool completeFired = false; bool completeData = false; var client = new GearmanClient(); client.JobCreated += (o, e) => createFired = true; client.JobCompleted += (o, e) => completeFired = true; client.JobCompleted += (o, e) => completeData = (e.Data.SequenceEqual(Encoding.ASCII.GetBytes("dlroW olleH"))); client.AddServer(Helpers.TestServerHost, Helpers.TestServerPort); var jobRequest = client.SubmitJob("reverse", Encoding.ASCII.GetBytes("Hello World")); Assert.IsTrue(createFired); Assert.IsTrue(completeFired); Assert.IsTrue(completeData); }