Esempio 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);
        }
Esempio n. 2
0
        /// <summary>
        /// This method creates the data collection container, which is responsible for logging, event source management, and telemetry.
        /// </summary>
        /// <returns>The data collection container.</returns>
        protected virtual DataCollectionContainer InitialiseDataCollectionContainer()
        {
            var container = new DataCollectionContainer(Policy.DataCollection);

            return(container);
        }
 internal DataCollectionWrapper(DataCollectionContainer dataCollection, Func <ServiceStatus> getStatus) : base(getStatus)
 {
     mDataCollection = dataCollection;
 }