Exemplo n.º 1
0
        /// <summary>
        /// This is the Microservice constructor.
        /// </summary>
        /// <param name="name">The Microservice name.</param>
        /// <param name="serviceId">The service id.</param>
        /// <param name="description">An optional description for the Microservice.</param>
        /// <param name="policySettings">The policy settings.</param>
        /// <param name="properties">Any additional property key.</param>
        /// <param name="serviceVersionId">This is the version id of the calling assembly as a string.</param>
        public Microservice(
            string name          = null
            , string serviceId   = null
            , string description = null
            , IEnumerable <PolicyBase> policySettings          = null
            , IEnumerable <Tuple <string, string> > properties = null
            , string serviceVersionId = null
            )
            : base(name)
        {
            Policy = new PolicyWrapper(policySettings, () => Status);
            //Id
            if (string.IsNullOrEmpty(name))
            {
                name = GetType().Name;
            }

            Id = new MicroserviceId(name
                                    , serviceId: serviceId
                                    , description: description
                                    , serviceVersionId: serviceVersionId ?? Assembly.GetCallingAssembly().GetName().Version.ToString()
                                    , serviceEngineVersionId: GetType().Assembly.GetName().Version.ToString()
                                    , properties: properties);
            //Security
            mSecurity = InitialiseSecurityContainer();
            Security  = new SecurityWrapper(mSecurity, () => Status);
            //Communication
            mCommunication = InitialiseCommunicationContainer();
            Communication  = new CommunicationWrapper(mCommunication, () => Status);
            //Commands
            mCommands = InitialiseCommandContainer();
            Commands  = new CommandWrapper(mCommands, () => Status);
            //Resources
            mResourceMonitor = InitialiseResourceMonitor();
            ResourceMonitor  = new ResourceWrapper(mResourceMonitor, () => Status);
            //Data Collection
            mDataCollection = InitialiseDataCollectionContainer();
            DataCollection  = new DataCollectionWrapper(mDataCollection, () => Status);
            //Events
            mEventsWrapper = new EventsWrapper(this, mDataCollection, () => Status);
            Events         = mEventsWrapper;
            //Serializer
            mSerializer   = InitialiseSerializationContainer();
            Serialization = new SerializationWrapper(mSerializer, () => Status);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method creates the communication container. This container comtains all the
        /// listeners and senders registered on the service, and assigns priority when polling for
        /// new incoming requests.
        /// </summary>
        /// <returns>The communication container.</returns>
        protected virtual CommunicationContainer InitialiseCommunicationContainer()
        {
            var container = new CommunicationContainer(Policy.Communication);

            return(container);
        }
Exemplo n.º 3
0
 internal CommunicationWrapper(CommunicationContainer communication, Func <ServiceStatus> getStatus) : base(getStatus)
 {
     mCommunication = communication;
 }