コード例 #1
0
ファイル: Program.cs プロジェクト: zredb/GearmanSharp
 private static void CreateJobs(GearmanClient client, int jobCount)
 {
     for (int i = 0; i < jobCount; i++)
     {
         var result = client.SubmitJob <string, string>("reverse", String.Format("{0}: Hello World", i),
                                                        Serializers.UTF8StringSerialize, Serializers.UTF8StringDeserialize);
         Console.WriteLine("Job result: {0}", result);
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: issacg/GearmanSharp
 private static void CreateJobs(GearmanClient client, int jobCount)
 {
     for (int i = 0; i < jobCount; i++)
     {
         var result = client.SubmitJob<string, string>("reverse", String.Format("{0}: Hello World", i),
             Serializers.UTF8StringSerialize, Serializers.UTF8StringDeserialize);
         Console.WriteLine("Job result: {0}", result);
     }
 }
コード例 #3
0
ファイル: Example.cs プロジェクト: twingly/GearmanSharp
        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>>);
        }
コード例 #4
0
        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> >);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }