Class ALambdaTopicFunction<TMessage>
The ALambdaTopicFunction<TMessage> is the abstract base class for handling Amazon Simple Notification Service (SNS) events.
Implements
Inherited Members
Namespace: LambdaSharp.SimpleNotificationService
Assembly: LambdaSharp.SimpleNotificationService.dll
Syntax
public abstract class ALambdaTopicFunction<TMessage> : ALambdaFunction, ILambdaSharpLogger
Type Parameters
Name | Description |
---|---|
TMessage | The SNS topic message type. |
Constructors
ALambdaTopicFunction(ILambdaJsonSerializer)
Initializes a new ALambdaTopicFunction<TMessage> instance using the default implementation of ILambdaFunctionDependencyProvider.
Declaration
protected ALambdaTopicFunction(ILambdaJsonSerializer serializer)
Parameters
Type | Name | Description |
---|---|---|
ILambdaJsonSerializer | serializer | Custom implementation of ILambdaJsonSerializer. |
ALambdaTopicFunction(ILambdaJsonSerializer, ILambdaFunctionDependencyProvider)
Initializes a new ALambdaTopicFunction<TMessage> instance using a custom implementation of ILambdaFunctionDependencyProvider.
Declaration
protected ALambdaTopicFunction(ILambdaJsonSerializer serializer, ILambdaFunctionDependencyProvider provider)
Parameters
Type | Name | Description |
---|---|---|
ILambdaJsonSerializer | serializer | Custom implementation of ILambdaJsonSerializer. |
ILambdaFunctionDependencyProvider | provider | Custom implementation of ILambdaFunctionDependencyProvider. |
Properties
CurrentRecord
The CurrentRecord property holds the SNS message record that is currently being processed.
Declaration
protected SNSEvent.SNSMessage CurrentRecord { get; }
Property Value
Type | Description |
---|---|
Amazon.Lambda.SNSEvents.SNSEvent.SNSMessage | The Amazon.Lambda.SNSEvents.SNSEvent.SNSMessage instance. |
Remarks
This property is only set during the invocation of ProcessMessageAsync(TMessage). Otherwise, it returns null
.
LambdaSerializer
An instance of ILambdaJsonSerializer used for serializing/deserializing JSON data.
Declaration
protected ILambdaJsonSerializer LambdaSerializer { get; }
Property Value
Type | Description |
---|---|
ILambdaJsonSerializer | The ILambdaJsonSerializer instance. |
Methods
Deserialize(String)
The Deserialize(String) method converts the SNS topic message from string to a typed instance.
Declaration
public virtual TMessage Deserialize(string body)
Parameters
Type | Name | Description |
---|---|---|
System.String | body | The SNS topic message. |
Returns
Type | Description |
---|---|
TMessage | The deserialized SNS topic message. |
Remarks
This method invokes Amazon.Lambda.Core.ILambdaSerializer.Deserialize``1(System.IO.Stream) to convert the SNS topic message string
into a
ProcessMessageAsync(TMessage)
The ProcessMessageAsync(TMessage) method is invoked for every received SNS topic message.
Declaration
public abstract Task ProcessMessageAsync(TMessage message)
Parameters
Type | Name | Description |
---|---|---|
TMessage | message | The deserialized SNS topic message. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | The task object representing the asynchronous operation. |
ProcessMessageStreamAsync(Stream)
The ProcessMessageStreamAsync(Stream) method is overridden to provide specific behavior for this base class.
Declaration
public sealed override async Task<Stream> ProcessMessageStreamAsync(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream with the request payload. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.IO.Stream> | The task object representing the asynchronous operation. |
Overrides
Remarks
This method cannot be overridden.