Exemple #1
0
        public void Start()
        {
            RavenDbManager.Start();
            var ep = new IPEndPoint(IPAddress.Any, 20589);

            KayakGate.Start(new SchedulerDelegate(), ep, AppBuilder.BuildConfiguration(_Configuration), _context);
        }
Exemple #2
0
        public Listener(IPEndPoint listeningEndpoint, ISchedulerDelegate schedulerDelegate)
        {
            _listeningEndpoint   = listeningEndpoint;
            _schedulerDelegate   = schedulerDelegate;
            _applicationDelegate = AppBuilder.BuildConfiguration(x => RunExtensions.Run(x.RescheduleCallbacks(), _host.ExecuteRequest));

            _scheduler = KayakScheduler.Factory.Create(_schedulerDelegate);
            _server    = KayakServer.Factory.CreateGate(_applicationDelegate, _scheduler, null);
        }
Exemple #3
0
        public void Bind(
            ref CrosswalkModule.BindHandlerContext binding,
            out CrosswalkModule.ExecuteHandlerDelegate executeHandler)
        {
            var app     = AppBuilder.BuildConfiguration(binding.ScriptProcessor);
            var handler = new Handler(app);

            executeHandler = handler.Execute;
        }
Exemple #4
0
        public void LaunchScheduler(KayakOptions options)
        {
            // okay the default delegate kinds sucks because if the user's program doesn't
            // explicitly call stop the thread essentially hangs, becaues the event loop
            // frame never returns, it's just waiting on another task.
            //
            // something of a halting problem.
            // would be better if scheduler just stopped when no more callbacks were queued.
            //
            // for now, you should use gate if you don't provide a delegate. scheduler and process args
            // are passed in via env. call stop eventually, or be okay with your program never terminating

            var kayakDelegate =
                new KayakDelegateLoader().Load(options.KayakConfiguration)
                ?? new DefaultKayakDelegate();

            var scheduler = KayakScheduler.Factory.Create(kayakDelegate);

            scheduler.Post(() => kayakDelegate.OnStart(scheduler, options.RemainingArguments));

            var gateOptions = options.GateOptions;

            if (gateOptions != null)
            {
                var gateConfiguration = gateOptions.GateConfiguration;
                var listenEndPoint    = gateOptions.ListenEndPoint ?? new IPEndPoint(IPAddress.Any, 8000);

                var context = new Dictionary <string, object>()
                {
                    { "kayak.ListenEndPoint", listenEndPoint },
                    { "kayak.Arguments", options.RemainingArguments }
                };

                var config = DefaultConfigurationLoader.LoadConfiguration(gateConfiguration);

                if (config == null)
                {
                    throw new Exception("Could not load Gate configuration from configuration string '" + gateConfiguration + "'");
                }

                var app = AppBuilder.BuildConfiguration(config);

                var server = KayakServer.Factory.CreateGate(app, scheduler, context);

                scheduler.Post(() =>
                {
                    Console.WriteLine("kayak: binding gate app to '" + listenEndPoint + "'");
                    server.Listen(listenEndPoint);
                });
            }

            // blocks until Stop is called
            scheduler.Start();
        }
Exemple #5
0
    void StartScheduler()
    {
        var schedulerDelegate = new SchedulerDelegate
        {
            Logger = Logger
        };

        scheduler = KayakScheduler.Factory.Create(schedulerDelegate);

        var endPoint1   = new IPEndPoint(IPAddress.Any, 91);
        var appDelegate = AppBuilder.BuildConfiguration(Startup.Configuration);

        using (KayakServer.Factory.CreateGate(appDelegate, scheduler, null)
               .Listen(endPoint1))
        {
            scheduler.Start();
        }
    }
Exemple #6
0
        public void RunApplication(int port, Action <FubuRuntime> activation)
        {
            _port = port;


            _listeningEndpoint = new IPEndPoint(IPAddress.Any, _port);
            Console.WriteLine("Listening on " + _listeningEndpoint);

            _applicationDelegate = AppBuilder.BuildConfiguration(x => x.RescheduleCallbacks().Run(ExecuteRequest));

            _scheduler = KayakScheduler.Factory.Create(_schedulerDelegate);
            _server    = KayakServer.Factory.CreateGate(_applicationDelegate, _scheduler, null);

            if (_listeningEndpoint == null)
            {
                throw new InvalidOperationException("Start() can only be called after RunApplication() and Stop()");
            }

            var runtime = rebuildFubuMVCApplication();

            _kayakListenerDisposer = _server.Listen(_listeningEndpoint);
            _scheduler.Post(() => ThreadPool.QueueUserWorkItem(o => activation(runtime)));
            _scheduler.Start();
        }