Ejemplo n.º 1
0
        public ShelfServiceController(Inbox inbox, string name, IServiceChannel coordinatorChannel, ShelfType shelfType,
                                      Type bootstrapperType, AssemblyName[] assemblyNames)
        {
            _inbox            = inbox;
            _name             = name;
            _publish          = new PublishChannel(coordinatorChannel, inbox);
            _shelfType        = shelfType;
            _bootstrapperType = bootstrapperType;
            _assemblyNames    = assemblyNames;

            _inbox.Loop(loop =>
            {
                loop.Receive <ShelfCreated>(x =>
                {
                    ShelfCreated(x);
                    loop.Continue();
                });

                loop.Receive <ServiceUnloaded>(x =>
                {
                    ShelfUnloaded(x);
                    loop.Continue();
                });
            });
        }
Ejemplo n.º 2
0
        // Henrik: I removed the finalizer, no unmanaged objects. See
        // http://blogs.msdn.com/b/tom/archive/2008/04/25/understanding-when-to-use-a-finalizer-in-your-net-class.aspx

        void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }
            if (disposing)
            {
                if (_scheduler != null)
                {
                    _scheduler.Stop(30.Seconds());
                }

                _fiber.Shutdown(30.Seconds());

                if (_producer != null)
                {
                    _producer.Dispose();
                }

                _serviceChannel = null;
            }

            _disposed = true;
        }
Ejemplo n.º 3
0
        public DirectoryMonitor(string directory, IServiceChannel serviceChannel)
        {
            _pendingNotifications = new Dictionary<string, ScheduledOperation>();

            _baseDirectory = directory;
            _serviceChannel = serviceChannel;
            _fiber = new PoolFiber();
        }
Ejemplo n.º 4
0
        public DirectoryMonitor(string directory, IServiceChannel serviceChannel)
        {
            _pendingNotifications = new Dictionary <string, ScheduledOperation>();

            _baseDirectory  = directory;
            _serviceChannel = serviceChannel;
            _fiber          = new PoolFiber();
        }
Ejemplo n.º 5
0
 public FilterContext(Type retType, Parameters parameters, IServiceChannel serviceChannel, LinkedListNode <T> filterNode)
 {
     RetType        = retType;
     Parameters     = parameters;
     ServiceChannel = serviceChannel;
     filter_node    = filterNode;
     NextContext    = CreateNextContext();
 }
Ejemplo n.º 6
0
        public IServiceController Build(Inbox inbox, IServiceChannel coordinatorChannel)
        {
            var serviceController = new LocalServiceController <T>(Name,
                                                                   inbox,
                                                                   coordinatorChannel,
                                                                   StartService,
                                                                   StopService,
                                                                   PauseService,
                                                                   ContinueService,
                                                                   CreateService);

            return(serviceController);
        }
        static void Main(string[] args)
        {
            ChannelFactory <IServiceChannel> channelFactory;

            channelFactory = new ChannelFactory <IServiceChannel>(new BasicHttpRelayBinding(), "https://azurerelaytest.servicebus.windows.net/azurerelayservice");
            channelFactory.Endpoint.Behaviors.Add(new TransportClientEndpointBehavior
            {
                TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("SharedAccessKey", "5YEwr1YFY3V7AThi2k/Mldaezr+m6lg5PP5cumlkYUo=")
            });
            // Create the Communication to the WCF
            IServiceChannel channel = channelFactory.CreateChannel();

            // Call the Service Method using Channel
            Console.WriteLine("Approval for 50? ->" + channel.GetApproval(50));
            Console.WriteLine("Approval for 500? ->" + channel.GetApproval(500));
            Console.ReadLine();
        }
Ejemplo n.º 8
0
        public object CallExceptionFilter <Excp>(Excp value,
                                                 Type retType,
                                                 Parameters parameters,
                                                 IServiceChannel serviceChannel) where Excp : Exception
        {
            if (ExceptionFilters.Count == 0)
            {
                return(null);
            }
            var context = new ExceptionFilterContext(retType, parameters, serviceChannel, ExceptionFilters.First);
            var obj     = context.Invoke(null, value);

            if (!context.ExceptionHandled)
            {
                throw new ProviderException(value.GetBaseException().Message);
            }
            return(obj);
        }
Ejemplo n.º 9
0
        public LocalServiceController(string name,
                                      Inbox inbox,
                                      IServiceChannel coordinatorChannel,
                                      Action <TService> startAction,
                                      Action <TService> stopAction,
                                      Action <TService> pauseAction,
                                      Action <TService> continueAction,
                                      InternalServiceFactory <TService> serviceFactory)
        {
            _name  = name;
            _inbox = inbox;
            _coordinatorChannel = coordinatorChannel;
            _startAction        = startAction;
            _continueAction     = continueAction;
            _serviceFactory     = serviceFactory;
            _pauseAction        = pauseAction;
            _stopAction         = stopAction;

            _log = LogManager.GetLogger("Topshelf.Host.Service." + name);
        }
Ejemplo n.º 10
0
        public string MakeServiceCall()
        {
            // Validate the specified Email address

            IServiceChannel proxy    = proxyFactory.CreateChannel();;
            var             response = "";

            try
            {
                proxy.Open();
                response = proxy.GetData();

                // Do some processing on the results

                proxy.Close();

                return(response);
            }
            catch (Exception e)
            {
                proxy.Abort();
            }
            return(response);
        }
Ejemplo n.º 11
0
 public PublishChannel(IServiceChannel channel, UntypedChannel inbox)
 {
     _channel = channel;
     _inbox   = inbox;
 }
 public ChannelController(IHttpContextAccessor httpContextAccessor, IUnitOfWork unityOfWork, IServiceChannel serviceChannel) : base(unityOfWork)
 {
     _serviceChannel      = serviceChannel;
     _httpContextAccessor = httpContextAccessor;
 }
Ejemplo n.º 13
0
 public TopshelfDashboard(ServiceDescription description, IServiceChannel serviceCoordinator)
 {
     _description        = description;
     _serviceCoordinator = serviceCoordinator;
     _port = 8483;
 }
Ejemplo n.º 14
0
 public MessageFilterContext(Type retType, Parameters parameters,
                             IServiceChannel serviceChannel,
                             LinkedListNode <IMessageFilter> filterNode) : base(retType, parameters, serviceChannel, filterNode)
 {
 }
Ejemplo n.º 15
0
 public MistyService(IServiceChannel channel)
 {
     _channel = channel;
 }
Ejemplo n.º 16
0
Archivo: Host.cs Proyecto: haf/Topshelf
 public Host(IServiceChannel serviceChannel)
 {
     _serviceChannel = serviceChannel;
 }
Ejemplo n.º 17
0
 public StatusChannel(IServiceChannel serviceCoordinator)
 {
     _serviceCoordinator = serviceCoordinator;
 }
Ejemplo n.º 18
0
        void Dispose(bool disposing)
        {
            if (_disposed)
                return;
            if (disposing)
            {
                if (_scheduler != null)
                    _scheduler.Stop(30.Seconds());

                _fiber.Shutdown(30.Seconds());

                if (_producer != null)
                    _producer.Dispose();

                _serviceChannel = null;
            }

            _disposed = true;
        }
Ejemplo n.º 19
0
 T CreateService(string name, IServiceChannel coordinatorChannel)
 {
     return(_factory(_description, name, coordinatorChannel));
 }
Ejemplo n.º 20
0
 public ShelfHost(IServiceChannel serviceChannel)
 {
     _serviceChannel = serviceChannel;
 }
Ejemplo n.º 21
0
 public CommandProcessor(IServiceChannel coordinatorChannel)
 {
     _coordinatorChannel = coordinatorChannel;
 }
Ejemplo n.º 22
0
 public DirectoryMonitor(string directory, IServiceChannel serviceChannel)
 {
     _baseDirectory  = directory;
     _serviceChannel = serviceChannel;
     _fiber          = new PoolFiber();
 }
Ejemplo n.º 23
0
 public Host(IServiceChannel serviceChannel)
 {
     _serviceChannel = serviceChannel;
 }
Ejemplo n.º 24
0
 public ShelfHost(IServiceChannel serviceChannel)
 {
     _serviceChannel = serviceChannel;
 }
Ejemplo n.º 25
0
 public ApplicationHost(IServiceChannel serviceChannel)
 {
     _serviceChannel = serviceChannel;
 }
Ejemplo n.º 26
0
 public DashboardConnectionHandler(IServiceChannel serviceCoordinator)
     : base("^/$", "GET")
 {
     _serviceCoordinator = serviceCoordinator;
 }
Ejemplo n.º 27
0
 //: this()
 //private NancyHost _host;
 /*
 public DeploymentService()
 {
 */
 /*
     _timer = new Timer(3000) { AutoReset = true };
     _timer.Elapsed += (sender, eventArgs) => TimedMessageProcessor();
 */
 /*
 }
 */
 public DeploymentService(ServiceDescription description, IServiceChannel coordinatorChannel)
 {
     _description = description;
     _coordinatorChannel = coordinatorChannel;
 }
Ejemplo n.º 28
0
 public static IServiceChannel <T, T> RegisterNotify <T>(this IServiceChannel <T> channel, IService <object> decorator)
 => new ServiceChannel <T, T>(channel, channel, decorator);
Ejemplo n.º 29
0
 public TopshelfDashboard(ServiceDescription description, IServiceChannel serviceCoordinator)
 {
     _serviceCoordinator = serviceCoordinator;
     TinyIoC.TinyIoCContainer.Current.Register<IServiceChannel>(_serviceCoordinator);
 }
Ejemplo n.º 30
0
 public DirectoryMonitor(string directory, IServiceChannel serviceChannel)
 {
     _baseDirectory = directory;
     _serviceChannel = serviceChannel;
     _fiber = new PoolFiber();
 }
Ejemplo n.º 31
0
        public object CallMessageFilter(object value, Type retType, Parameters parameters, IServiceChannel serviceChannel)
        {
            if (MessageFilters.Count == 0)
            {
                return(value);
            }
            var message = new MessageFilterContext(retType, parameters, serviceChannel, MessageFilters.First);

            return(message.Invoke(null, value));
        }
Ejemplo n.º 32
0
 public TopshelfDashboard(ServiceDescription description, IServiceChannel serviceCoordinator)
 {
     _description = description;
     _serviceCoordinator = serviceCoordinator;
     _port = 8483;
 }
Ejemplo n.º 33
0
        private static IEnumerable<dynamic> GetServices(IServiceChannel serviceCoordinator)
        {
            var result = new Future<IEnumerable<dynamic>>();

            AnonymousActor.New(inbox =>
            {
                serviceCoordinator.Send<Request<ServiceStatus>>(new RequestImpl<ServiceStatus>(inbox, new ServiceStatus()));

                inbox.Receive<Response<ServiceStatus>>(response =>
                {
                    var report = from service in response.Body.Services
                             select new
                                 {
                                     Name = Uri.EscapeUriString(service.Name),
                                     service.ServiceType,
                                     service.CurrentState,
                                     Action = (service.CurrentState == "Running") ? "stop" : "start"
                                 };

                    result.Complete(report);

                }, 10.Seconds(), () =>
                {
                    var report = new[] { new { Name = "Failed to get Services list" } };

                    result.Complete(report);
                });
            });

            result.WaitUntilCompleted(20.Seconds());

            return result.Value;
        }