Skip to content

Commit cb9f6b3

Browse files
committed
Update docs for amazon-sqs transport along with config validation
1 parent 5d13455 commit cb9f6b3

4 files changed

Lines changed: 155 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using FluentValidation;
2+
3+
namespace BuslyCLI.Config.Validators;
4+
5+
public class AmazonsqsTransportConfigValidator : AbstractValidator<AmazonsqsTransportConfig>
6+
{
7+
public AmazonsqsTransportConfigValidator()
8+
{
9+
RuleFor(x => x.RegionName)
10+
.NotEmpty();
11+
12+
RuleFor(x => x.ServiceUrl)
13+
.NotEmpty();
14+
}
15+
}

src/BuslyCLI.Console/Config/Validators/TransportConfigValidator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public TransportConfigValidator()
1616
v.Add(new LearningTransportConfigValidator());
1717
v.Add(new RabbitMQTransportConfigValidator());
1818
v.Add(new AzureServiceBusTransportConfigValidator());
19+
v.Add(new AmazonsqsTransportConfigValidator());
1920
});
2021

2122
// RuleFor(x => x.LearningTransportConfig)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using BuslyCLI.Config;
2+
using BuslyCLI.Config.Validators;
3+
using FluentValidation.TestHelper;
4+
5+
namespace BuslyCLI.Console.Tests.Config.Validators;
6+
7+
[TestFixture]
8+
public class AmazonsqsTransportConfigValidatorTests
9+
{
10+
private readonly AmazonsqsTransportConfigValidator _validator;
11+
12+
public AmazonsqsTransportConfigValidatorTests()
13+
{
14+
_validator = new AmazonsqsTransportConfigValidator();
15+
}
16+
17+
[Test]
18+
public async Task ShouldErrorWhenRegionNameIsNotPassed()
19+
{
20+
// Arrange
21+
var amazonsqsTransportConfig = new AmazonsqsTransportConfig
22+
{
23+
RegionName = null
24+
};
25+
26+
// Act
27+
var result = await _validator.TestValidateAsync(amazonsqsTransportConfig);
28+
29+
// Assert
30+
result.ShouldHaveValidationErrorFor(c => c.RegionName)
31+
.WithErrorMessage("'Region Name' must not be empty.");
32+
}
33+
34+
[Test]
35+
public async Task ShouldNotErrorWhenRegionNameIsPassed()
36+
{
37+
// Arrange
38+
var amazonsqsTransportConfig = new AmazonsqsTransportConfig
39+
{
40+
RegionName = "us-east-1"
41+
};
42+
// Act
43+
var result = await _validator.TestValidateAsync(amazonsqsTransportConfig);
44+
45+
// Assert
46+
result.ShouldNotHaveValidationErrorFor(c => c.RegionName);
47+
}
48+
49+
[Test]
50+
public async Task ShouldErrorWhenServiceUrlIsNotPassed()
51+
{
52+
// Arrange
53+
var amazonsqsTransportConfig = new AmazonsqsTransportConfig
54+
{
55+
RegionName = null
56+
};
57+
58+
// Act
59+
var result = await _validator.TestValidateAsync(amazonsqsTransportConfig);
60+
61+
// Assert
62+
result.ShouldHaveValidationErrorFor(c => c.ServiceUrl)
63+
.WithErrorMessage("'Service Url' must not be empty.");
64+
}
65+
66+
[Test]
67+
public async Task ShouldNotErrorWhenServiceUrlIsPassed()
68+
{
69+
// Arrange
70+
var amazonsqsTransportConfig = new AmazonsqsTransportConfig
71+
{
72+
ServiceUrl = "us-east-1"
73+
};
74+
// Act
75+
var result = await _validator.TestValidateAsync(amazonsqsTransportConfig);
76+
77+
// Assert
78+
result.ShouldNotHaveValidationErrorFor(c => c.ServiceUrl);
79+
}
80+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Amazon SQS
2+
3+
The **Amazon SQS Transport** is used to communicate to Amazon SQS.
4+
5+
## Configuration
6+
7+
To use the Amazon SQS Transport, define it under `transports` and reference it as `current-transport`.
8+
9+
### Example
10+
11+
```yaml
12+
current-transport: local-stack-amazon-sqs
13+
14+
transports:
15+
- name: local-stack-amazon-sqs
16+
amazonsqs-transport-config:
17+
service-url: http://127.0.0.1:32813/
18+
region-name: us-east-1
19+
```
20+
21+
:::info
22+
23+
The Amazon SQS transport implementation currently works only with the LocalStack emulator.
24+
Pull requests to improve functionality or add support for live AWS SQS are welcome and much appreciated!
25+
26+
:::
27+
28+
---
29+
30+
## `amazonsqs-transport-config` Fields
31+
32+
| Field | Required | Type | Default | Description |
33+
| ------------- | -------- | ------ | ------- | ------------------------------- |
34+
| `service-url` | **Yes** | string | — | The Service Url for Amazon SQS. |
35+
| `region-name` | **Yes** | string | — | The region (EX: us-east-1). |
36+
37+
---
38+
39+
## Field Details
40+
41+
### `service-url` (required)
42+
43+
The Service Url for Amazon SQS.
44+
45+
Examples:
46+
47+
```yaml
48+
service-url: http://127.0.0.1:32813/
49+
```
50+
51+
### `region-name` (optional)
52+
53+
Allows Busly to interact with the RabbitMQ Management API for monitoring or queue management.
54+
55+
Examples:
56+
57+
```yaml
58+
region-name: us-east-1
59+
```

0 commit comments

Comments
 (0)