Esempio n. 1
0
        public async Task <bool> SaveUnstableRecord(UnstableRuleRecord newRecord)
        {
            if (!createConnection())
            {
                // failed to establish connection
                return(false);
            }

            var dbRecord = new UnstableServiceDbRecord(
                newRecord.serviceId,
                newRecord.downCount,
                newRecord.downEvents,
                newRecord.time);

            var collection = database.GetCollection <UnstableServiceDbRecord>(
                config.unstableRecordCollection);

            try
            {
                await collection.InsertOneAsync(dbRecord);

                return(true);
            }
            catch (TimeoutException)
            {
                Console.WriteLine($"Failed to connect with the database on: "
                                  + $"{config.dbAddress} ... ");

                return(false);
            }
        }
Esempio n. 2
0
 public UnstableServiceRequest(UnstableRuleRecord record)
 {
     this.record = record;
 }