Interface IStorageManager
An implementation of a storage medium that can be configured (via StorageType, StorageConnectionString, and StorageBasePath) for the web/task services to share
This permits easy saving/loading of files, and for queue messages
The default implementations for this by the LemonEdge platform are a simple file storage implementation and an Azure blob/queue service implementation.Namespace: LemonEdge.API.Storage
Assembly: API.dll
Syntax
public interface IStorageManager
Methods
Dequeue(String, TimeSpan)
Retrieves the first of any visible messsages sitting in the specified queue
Declaration
Task<(string Msg, object removeHandle)> Dequeue(string queueName, TimeSpan hideFor)
Parameters
Type | Name | Description |
---|---|---|
System.String | queueName | The name of the queue to retrieve any visible messages from |
System.TimeSpan | hideFor | The timespan to hide the message from the queue. If the item is not RmoveFromQueue(String, Object) within that timeframe then it is assumed the consumer failed somehow and the message becomes visible in the queue again for another consumer to process |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.ValueTuple<System.String, System.Object>> | If a message is found it is returned along with a handle that can be used to permanently remove the message from the queue |
GetFile(String, Int64, Guid, Nullable<Guid>, String, String, Nullable<Guid>)
Returns the specified file from the backing storage
Declaration
Task<byte[]> GetFile(string dbAlias, long accountID, Guid typeID, Guid? id, string fileName, string folder = "", Guid? teamID = default(Guid? ))
Parameters
Type | Name | Description |
---|---|---|
System.String | dbAlias | The unique database connection alias |
System.Int64 | accountID | The unique account id this request originates from |
System.Guid | typeID | The type of entity that this file is associated with |
System.Nullable<System.Guid> | id | The optional id of the entity type that this file is associated with |
System.String | fileName | The name of the file being retrieved |
System.String | folder | A folder this file is located within |
System.Nullable<System.Guid> | teamID | The optional team this file is for to prevent those with other permissions from retrieving this file |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Byte[]> | A task holding the retrieved file in byte form |
GetFile(String, String)
Returns the specified file from the backing storage
Declaration
Task<byte[]> GetFile(string path, string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to retrieve this file from |
System.String | fileName | The name of the file being retrieved |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Byte[]> | A task holding the retrieved file in byte form |
Init(String, String)
Connects to a new IStorageManager with the specified connectionstring and base path
Declaration
void Init(string connectionString, string baseFolder)
Parameters
Type | Name | Description |
---|---|---|
System.String | connectionString | A connection string to connect to the storage service |
System.String | baseFolder | A default base path for this storage manager to use |
Queue(String, String)
Adds the specified message to the specified queue
Declaration
Task Queue(string queueName, string msg)
Parameters
Type | Name | Description |
---|---|---|
System.String | queueName | The name of the queue to add the message to |
System.String | msg | The message to add to the queue |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
Queue(String, String, TimeSpan)
Adds the specified message to the specified queue with a delay indicating when it is available to be dequeued
Declaration
Task Queue(string queueName, string msg, TimeSpan hiddenFor)
Parameters
Type | Name | Description |
---|---|---|
System.String | queueName | The name of the queue to add the message to |
System.String | msg | The message to add to the queue |
System.TimeSpan | hiddenFor | A timespan indicating the period that must elapse before the message is visible and can be retireved from the queue |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
RmoveFromQueue(String, Object)
When a message has been retrieved from a queue, it is not removed until the consumer has a chance to correctly process it.
When it has been correctly processed this function removes the message permanently from the queue.
If this is not called within the timeout of the Dequeue(String, TimeSpan) call then the message will be added back to the queue for processing by another consumerDeclaration
Task RmoveFromQueue(string queueName, object removeHandle)
Parameters
Type | Name | Description |
---|---|---|
System.String | queueName | The name of the queue to permanently remove a message from |
System.Object | removeHandle | The unique handle to the message to remove |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
WriteStream(String, Int64, Stream, Guid, Nullable<Guid>, String, String, Nullable<Guid>)
Writes the specified stream to the backing storage for the specified location
Declaration
Task WriteStream(string dbAlias, long accountID, Stream stream, Guid typeID, Guid? id, string fileName, string folder = "", Guid? teamID = default(Guid? ))
Parameters
Type | Name | Description |
---|---|---|
System.String | dbAlias | The unique database connection alias |
System.Int64 | accountID | The unique account id this request originates from |
System.IO.Stream | stream | The stream to write to backing storage |
System.Guid | typeID | The type of entity that this stream is associated with |
System.Nullable<System.Guid> | id | The optional id of the entity type that this stream is associated with |
System.String | fileName | The name of the file being saved |
System.String | folder | A folder to place this file within |
System.Nullable<System.Guid> | teamID | The optional team this file is for to prevent those with other permissions from retrieving this file |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task inidicating the completion of this operation |
WriteStream(String, String, Stream)
Writes the specified stream to the backing storage for the specified location
Declaration
Task WriteStream(string path, string fileName, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to store this stream in |
System.String | fileName | The name of the file being saved |
System.IO.Stream | stream | The stream to write to backing storage |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of this operation |