コード例 #1
0
        public async Task FunctionHandler(S3NotificationEvent input, ILambdaContext context)
        {
            var data      = input?.GetFileData();
            var retriever = new S3ObjectRetriever(data.Value.objectsKey,
                                                  RegionEndpoint.GetBySystemName(data.Value.region));

            using var connection = new DbConnection();
            await connection.GetConnection().OpenAsync().ConfigureAwait(false);

            var    logSaver = new LogSaver(connection.GetConnection());
            string logId    = await logSaver.GetAssociatedLogIdAsync(data.Value.objectsKey).ConfigureAwait(false);

            if (!String.IsNullOrEmpty(logId))
            {
                var entries = retriever.GetObjectDataAsync().Select(
                    logLine => EntryParser.ProcessLogLine(logLine));
                await logSaver.SaveLogsAsync(logId, entries).ConfigureAwait(false);

                if (NotificationSender.IsNotificationNecessary(data.Value.objectsKey))
                {
                    await NotificationSender.TryPublishNotification(data.Value.objectsKey).ConfigureAwait(false);
                }
            }
            else
            {
                throw new Exception($"Log with given object name " +
                                    $"({data.Value.objectsKey}) has no associated record in database");
            }
        }
コード例 #2
0
        public void TestProcessLogLineMatchUserAgent(string logLine, string expectedUserAgent)
        {
            var logEntry = EntryParser.ProcessLogLine(logLine);

            Assert.Equal(expectedUserAgent, logEntry.UserAgent);
        }
コード例 #3
0
        public void TestProcessLogLineMatchRawEntry(string logLine)
        {
            var logEntry = EntryParser.ProcessLogLine(logLine);

            Assert.Equal(logLine, logEntry.RawEntry);
        }
コード例 #4
0
        public void TestProcessLogLineMatchResponseCode(string logLine, int expectedResponseCode)
        {
            var logEntry = EntryParser.ProcessLogLine(logLine);

            Assert.Equal(expectedResponseCode, logEntry.ResponseCode);
        }
コード例 #5
0
        public void TestProcessLogLineMatchIP(string logLine, string expectedIP)
        {
            var logEntry = EntryParser.ProcessLogLine(logLine);

            Assert.Equal(expectedIP, logEntry.ClientIp);
        }
コード例 #6
0
        public void TestProcessLogLineMatchRequestTime(string logLine, DateTime expectedRequestTime)
        {
            var logEntry = EntryParser.ProcessLogLine(logLine);

            Assert.Equal(expectedRequestTime, logEntry.RequestTime);
        }
コード例 #7
0
        public void TestProcessLogLineMatchResource(string logLine, string expectedResource)
        {
            var logEntry = EntryParser.ProcessLogLine(logLine);

            Assert.Equal(expectedResource, logEntry.Resource);
        }
コード例 #8
0
        public void TestProcessLogLineMatchMethod(string logLine, LogEntry.RequestType expectedMethod)
        {
            var logEntry = EntryParser.ProcessLogLine(logLine);

            Assert.Equal(expectedMethod, logEntry.Method);
        }