Skip to content

Commit

Permalink
Merge pull request #32 from Particular/interface
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmarbach committed Jan 4, 2021
2 parents 370f476 + 68be4c4 commit a613c5b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
@@ -1,6 +1,6 @@
namespace NServiceBus
{
public class AwsLambdaSQSEndpoint
public class AwsLambdaSQSEndpoint : NServiceBus.IAwsLambdaSQSEndpoint
{
public AwsLambdaSQSEndpoint(System.Func<Amazon.Lambda.Core.ILambdaContext, NServiceBus.AwsLambdaSQSEndpointConfiguration> configurationFactory) { }
public System.Threading.Tasks.Task Process(Amazon.Lambda.SQSEvents.SQSEvent @event, Amazon.Lambda.Core.ILambdaContext lambdaContext, System.Threading.CancellationToken cancellationToken = default) { }
Expand All @@ -16,4 +16,8 @@ namespace NServiceBus
protected NServiceBus.TransportExtensions<TTransport> UseTransport<TTransport>()
where TTransport : NServiceBus.Transport.TransportDefinition, new () { }
}
public interface IAwsLambdaSQSEndpoint
{
System.Threading.Tasks.Task Process(Amazon.Lambda.SQSEvents.SQSEvent @event, Amazon.Lambda.Core.ILambdaContext lambdaContext, System.Threading.CancellationToken cancellationToken = default);
}
}
7 changes: 2 additions & 5 deletions src/NServiceBus.AwsLambda.SQS/AwsLambdaEndpoint.cs
Expand Up @@ -15,15 +15,14 @@
using Configuration.AdvancedExtensibility;
using Extensibility;
using Logging;
using Settings;
using SimpleJson;
using Transport;

/// <summary>
/// An NServiceBus endpoint hosted in AWS Lambda which does not receive messages automatically but only handles
/// messages explicitly passed to it by the caller.
/// </summary>
public class AwsLambdaSQSEndpoint
public class AwsLambdaSQSEndpoint : IAwsLambdaSQSEndpoint
{
/// <summary>
/// Create a new endpoint hosting in AWS Lambda.
Expand Down Expand Up @@ -75,7 +74,6 @@ async Task InitializeEndpointIfNecessary(ILambdaContext executionContext, Cancel
}
}


async Task Initialize(AwsLambdaSQSEndpointConfiguration configuration)
{
var settingsHolder = configuration.AdvancedConfiguration.GetSettings();
Expand Down Expand Up @@ -108,7 +106,6 @@ async Task<string> GetQueueUrl(string queueName)
Logger.Error($"Failed to obtain the queue URL for queue {sanitizedErrorQueueName} (derived from configured name {queueName}).", e);
throw;
}

}

async Task ProcessMessage(SQSEvent.SQSMessage receivedMessage, ILambdaContext lambdaContext, CancellationToken token)
Expand Down Expand Up @@ -246,7 +243,7 @@ async Task ProcessMessageWithInMemoryRetries(Dictionary<string, string> headers,
}
}
}

async Task Process(MessageContext messageContext, ILambdaContext executionContext)
{
await InitializeEndpointIfNecessary(executionContext, messageContext.ReceiveCancellationTokenSource.Token).ConfigureAwait(false);
Expand Down
19 changes: 19 additions & 0 deletions src/NServiceBus.AwsLambda.SQS/IAwsLambdaSQSEndpoint.cs
@@ -0,0 +1,19 @@
namespace NServiceBus
{
using System.Threading;
using System.Threading.Tasks;
using Amazon.Lambda.Core;
using Amazon.Lambda.SQSEvents;

/// <summary>
/// An NServiceBus endpoint hosted in AWS Lambda which does not receive messages automatically but only handles
/// messages explicitly passed to it by the caller.
/// </summary>
public interface IAwsLambdaSQSEndpoint
{
/// <summary>
/// Processes a messages received from an SQS trigger using the NServiceBus message pipeline.
/// </summary>
Task Process(SQSEvent @event, ILambdaContext lambdaContext, CancellationToken cancellationToken = default);
}
}

0 comments on commit a613c5b

Please sign in to comment.