Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 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);
     }
 }
Esempio n. 4
0
        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.
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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.
        }
Esempio n. 8
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>>);
        }
        /// <summary>
        /// Create a Gearman client connection.
        /// </summary>
        /// <param name="configurations"></param>
        /// <returns>GearmanClient with servers added</returns>
        public static GearmanClient createClientConnectionUsingGearman(GearmanServerConfiguration[] configurations)
        {
            var client = new GearmanClient();

            foreach (var config in configurations)
            {
                client.AddServer(config.Host, config.Port);
            }

            return(client);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
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> >);
        }
Esempio n. 12
0
        private static void CreateBackgroundJobs(GearmanClient client, int jobCount)
        {
            for (int i = 0; i < jobCount; i++)
            {
                var request = client.SubmitBackgroundJob("reverse_with_status", Encoding.UTF8.GetBytes(String.Format("{0}: Hello World", i)));

                GearmanJobStatus jobStatus;
                do
                {
                    jobStatus = client.GetStatus(request);
                }while (jobStatus.IsKnown && jobStatus.IsRunning);

                Console.WriteLine("Submitted background job. Handle: {0}", request.JobHandle);
            }
        }
Esempio n. 13
0
        private static void CreateBackgroundJobs(GearmanClient client, int jobCount)
        {
            for (int i = 0; i < jobCount; i++)
            {
                var request = client.SubmitBackgroundJob("reverse_with_status", Encoding.UTF8.GetBytes(String.Format("{0}: Hello World", i)));

                GearmanJobStatus jobStatus;
                do
                {
                    jobStatus = client.GetStatus(request);
                }
                while (jobStatus.IsKnown && jobStatus.IsRunning);

                Console.WriteLine("Submitted background job. Handle: {0}", request.JobHandle);
            }
        }
        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);
        }
        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);
        }
Esempio n. 16
0
        public void SimpleClient()
        {
            var client = new GearmanClient("gearmanCluster");

            var handle = client.SubmitBackgroundJob("reverse", Encoding.ASCII.GetBytes("helloworld"));
        }
Esempio n. 17
0
        public void SimpleClient()
        {
            var client = new GearmanClient("gearmanCluster");

            var handle = client.SubmitBackgroundJob("reverse", Encoding.ASCII.GetBytes("helloworld"));
        }