Ejemplo n.º 1
0
 /// <summary>
 /// This is the default constructor.
 /// </summary>
 /// <param name="credentials">The azure storage credentials.</param>
 /// <param name="keyMaker"></param>
 /// <param name="keyDeserializer"></param>
 /// <param name="storageIdMaker"></param>
 /// <param name="keySerializer"></param>
 /// <param name="entityName">The options entity name. If this is not presented then the entity name will be used.</param>
 /// <param name="versionPolicy">The versioning policy.</param>
 /// <param name="defaultTimeout">The default timeout for async requests.</param>
 /// <param name="accessType">The azure access type. BlobContainerPublicAccessType.Off is the default.</param>
 /// <param name="options">The optional blob request options.</param>
 /// <param name="context">The optional operation context.</param>
 /// <param name="persistenceRetryPolicy">Persistence retry policy</param>
 /// <param name="resourceProfile"></param>
 /// <param name="cacheManager"></param>
 /// <param name="referenceMaker"></param>
 /// <param name="encryption"></param>
 public PersistenceMessageHandlerAzureBlobStorageBase(StorageCredentials credentials
                                                      , Func <E, K> keyMaker
                                                      , Func <string, K> keyDeserializer
                                                      , Func <K, string> storageIdMaker = null
                                                      , Func <K, string> keySerializer  = null
                                                      , string entityName = null
                                                      , VersionPolicy <E> versionPolicy               = null
                                                      , TimeSpan?defaultTimeout                       = null
                                                      , BlobContainerPublicAccessType accessType      = BlobContainerPublicAccessType.Off
                                                      , BlobRequestOptions options                    = null
                                                      , OperationContext context                      = null
                                                      , PersistenceRetryPolicy persistenceRetryPolicy = null
                                                      , ResourceProfile resourceProfile               = null
                                                      , ICacheManager <K, E> cacheManager             = null
                                                      , Func <E, IEnumerable <Tuple <string, string> > > referenceMaker = null
                                                      , IServiceHandlerEncryption encryption = null
                                                      )
     : base(keyMaker, keyDeserializer
            , entityName: entityName
            , versionPolicy: versionPolicy
            , defaultTimeout: defaultTimeout
            , persistenceRetryPolicy: persistenceRetryPolicy
            , resourceProfile: resourceProfile
            , cacheManager: cacheManager
            , referenceMaker: referenceMaker
            , keySerializer: keySerializer
            )
 {
     mDirectory      = entityName ?? typeof(E).Name;
     mStorage        = new StorageServiceBase(credentials, "persistence", accessType, options, context, defaultTimeout: defaultTimeout, encryption: encryption);
     mStorageIdMaker = storageIdMaker ?? mTransform.KeySerializer;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// This is the default constructor.
        /// </summary>
        /// <param name="credentials">The azure credentials</param>
        /// <param name="containerName">The container name to store the entities.</param>
        /// <param name="accessType">The azure storage access type.</param>
        /// <param name="options">The blob request options.</param>
        /// <param name="context">The operation context.</param>
        /// <param name="defaultTimeout">The default timeout for the operations.</param>
        /// <param name="encryption">Encryption to be used when storing the blob</param>
        public StorageServiceBase(StorageCredentials credentials
                                  , string containerName
                                  , BlobContainerPublicAccessType accessType = BlobContainerPublicAccessType.Off
                                  , BlobRequestOptions options           = null
                                  , OperationContext context             = null
                                  , TimeSpan?defaultTimeout              = null
                                  , IServiceHandlerEncryption encryption = null)
        {
            if (credentials == null)
            {
                throw new ArgumentNullException("StorageServiceBase: Storage credentials cannot be null.");
            }

            if (containerName == null)
            {
                throw new ArgumentNullException("StorageServiceBase: Storage containerName cannot be null.");
            }

            mCredentails    = credentials;
            mContainerName  = ValidateAzureContainerName(containerName);
            mAccessType     = accessType;
            mOptions        = options ?? BlobRequestOptionsDefault;
            mContext        = context;
            mDefaultTimeout = defaultTimeout;
            mEncryption     = encryption;
        }
 /// <summary>
 /// This is the default constructor.
 /// </summary>
 /// <param name="credentials">The azure storage credentails.</param>
 /// <param name="serviceName">The service name to log under.</param>
 /// <param name="defaultTimeout">The default timeout for each message.</param>
 /// <param name="accessType">The blog storage access type. By default this is set to private.</param>
 /// <param name="options">The blod request options.</param>
 /// <param name="context">The options context.</param>
 /// <param name="encryption">Encryption to be used when logging dead letters</param>
 public DeadLetterLoggerMessageHandler(StorageCredentials credentials, string serviceName
                                       , TimeSpan?defaultTimeout = null
                                       , BlobContainerPublicAccessType accessType = BlobContainerPublicAccessType.Off
                                       , BlobRequestOptions options           = null
                                       , OperationContext context             = null
                                       , IServiceHandlerEncryption encryption = null)
 {
     mStorage     = new StorageServiceBase(credentials, "DeadLetter", accessType, options, context, defaultTimeout: defaultTimeout, encryption: encryption);
     mServiceName = serviceName;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// This method adds the encryption handler to the Microservice.
        /// </summary>
        /// <typeparam name="P">The pipeline type.</typeparam>
        /// <param name="pipeline">The pipeline.</param>
        /// <param name="handler">The handler instance.</param>
        /// <param name="action">The action on the handler.</param>
        /// <returns>The pipeline.</returns>
        public static P AddEncryptionHandler <P>(this P pipeline
                                                 , IServiceHandlerEncryption handler
                                                 , Action <IServiceHandlerEncryption> action = null)
            where P : IPipeline
        {
            action?.Invoke(handler);

            pipeline.Service.ServiceHandlers.Encryption.Add(handler);

            return(pipeline);
        }
 public PersistenceMondayMorningBluesBlob(StorageCredentials credentials
                                          , VersionPolicy <MondayMorningBlues> versionPolicy      = null
                                          , ICacheManager <Guid, MondayMorningBlues> cacheManager = null
                                          , IServiceHandlerEncryption encryption = null)
     : base(credentials, (k) => k.Id, (s) => new Guid(s), keySerializer: (g) => g.ToString("N").ToUpperInvariant(), cacheManager: cacheManager
            , versionPolicy: versionPolicy
            , referenceMaker: MondayMorningBluesHelper.ToReferences
            , encryption: encryption
            )
 {
 }
 /// <summary>
 /// This is the default constructor.
 /// </summary>
 /// <param name="credentials">The azure storage credentials.</param>
 /// <param name="directoryMaker"></param>
 /// <param name="defaultTimeout">The default timeout for async requests.</param>
 /// <param name="accessType">The azure access type. BlobContainerPublicAccessType.Off is the default.</param>
 /// <param name="options">The optional blob request options.</param>
 /// <param name="context">The optional operation context.</param>
 /// <param name="containerName"></param>
 /// <param name="serviceName"></param>
 /// <param name="idMaker"></param>
 /// <param name="resourceProfile"></param>
 /// <param name="encryption"></param>
 protected AzureStorageLoggingBase(StorageCredentials credentials
                                   , string containerName
                                   , string serviceName
                                   , Func <E, string> idMaker                 = null
                                   , Func <E, string> directoryMaker          = null
                                   , TimeSpan?defaultTimeout                  = null
                                   , BlobContainerPublicAccessType accessType = BlobContainerPublicAccessType.Off
                                   , BlobRequestOptions options               = null
                                   , OperationContext context                 = null
                                   , ResourceProfile resourceProfile          = null
                                   , IServiceHandlerEncryption encryption     = null)
 {
     mStorage         = new StorageServiceBase(credentials, containerName, accessType, options, context, defaultTimeout: defaultTimeout, encryption: encryption);
     mIdMaker         = idMaker ?? IdMaker;
     mDirectoryMaker  = directoryMaker ?? DirectoryMaker;
     mServiceName     = serviceName;
     mResourceProfile = resourceProfile;
 }
Ejemplo n.º 7
0
 public AzureStorageLogger(StorageCredentials credentials, string serviceName, string containerName = "log"
                           , ResourceProfile resourceProfile = null, IServiceHandlerEncryption encryption = null)
     : base(credentials, containerName, serviceName, resourceProfile: resourceProfile, encryption: encryption)
 {
 }