Ejemplo n.º 1
0
 public MongoGrainStorage(
     ILogger <MongoGrainStorage> logger,
     IGrainStateSerializer serializer,
     MongoDBGrainStorageOptions options)
 {
     this.logger     = logger;
     this.options    = options;
     this.serializer = serializer;
 }
Ejemplo n.º 2
0
 public MongoGrainStorage(
     IMongoClientFactory mongoClientFactory,
     ILogger <MongoGrainStorage> logger,
     IGrainStateSerializer serializer,
     IOptions <MongoDBGrainStorageOptions> options)
 {
     this.mongoClient = mongoClientFactory.Create(options.Value, "Storage");
     this.logger      = logger;
     this.options     = options.Value;
     this.serializer  = serializer;
 }
        private IMongoCollection <BsonDocument> GetCollection(string grainType, GrainReference grainReference, IGrainState grainState)
        {
            var options = this.options;

            if (options.ForType != null)
            {
                if (options.ForType.TryGetValue(grainType, out var newOptions))
                {
                    options = newOptions;
                }
            }

            string collectionName;

            collectionName = options.CollectionNameResolver(grainType, options, grainState, grainReference);

            return(database.GetCollection <BsonDocument>(collectionName));
        }
Ejemplo n.º 4
0
        public JsonGrainStateSerializer(ITypeResolver typeResolver, IGrainFactory grainFactory, MongoDBGrainStorageOptions options)
        {
            var jsonSettings = OrleansJsonSerializer.GetDefaultSerializerSettings(typeResolver, grainFactory);

            options?.ConfigureJsonSerializerSettings?.Invoke(jsonSettings);
            this.serializer = JsonSerializer.Create(jsonSettings);

            if (options?.ConfigureJsonSerializerSettings == null)
            {
                //// https://github.com/OrleansContrib/Orleans.Providers.MongoDB/issues/44
                //// Always include the default value, so that the deserialization process can overwrite default
                //// values that are not equal to the system defaults.
                this.serializer.NullValueHandling    = NullValueHandling.Include;
                this.serializer.DefaultValueHandling = DefaultValueHandling.Populate;
            }
        }
 public MongoDBGrainStorageOptionsValidator(MongoDBGrainStorageOptions options, string name)
 {
     this.options = options;
     this.name    = name;
 }