-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Report function into Attendees API
- Loading branch information
1 parent
6891450
commit 0324747
Showing
51 changed files
with
858 additions
and
1,055 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<mxfile host="app.diagrams.net" modified="2022-12-10T18:45:37.814Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.46" etag="eIX8-G3vbRCFldznsroz" version="20.6.0" type="google"><diagram id="1nrGd4S113_c-P8m6nDI" name="Page-1">3V1bd5pKGP01rnXOg1ncwceoyUl7kpOkpk3Sl64RRqVFxsAYtb/+DHIRZgYlyMX60C4YZMT9bb77TDryYL7+xwOL2R2yoNORhKlnWx152JEkkfwjAwswheGAEA4EnxjZv6NBMR5d2hb0M3dihBxsL7KDJnJdaOLMGPA8tMp+bIIc9jFGJnAgM/psW3gWjhqSvhu/gfZ0Fn+RqPXCK3MQfzh6cH8GLLRKDclXHXngIYTDo/l6AJ0AmRiX8L7rnKvJg3nQxUVu+DmU/vmOrr/40vJx/fT1efDSdbrxw70DZxn94uhp8SaGgExDwCUn/dXMxnC0AGZwZUWkScZmeO6QM5EcAn8RIj6x15B8a9/HHvoFB8hB3nYqWTMNOJ6QKxPbcVLjFoDGxCTj0dNAD8N17u8UE/QIpyCaQ+xtyEfiG4RIAptIVqIanq928tNiNs1SsksGQUSRaTL3DlZyECH7AZRFo1GUDWksaxoHZRUallIRyhqFsi4wKCs9DsrJ4DEoe3L/x5Nr6Pdf3pQ+cpzl2/V9V2ZAvsQYuhaEHUlzyNf3xx45muIEgRT8/sqeO8AtgH8F4GkxBhF4co8FT9Q54IlabeCp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AuzNe0iDi2rFwG778nokY1ZUYjYINmPLeCkBfxZQtCY27dgDJ0H5NvYRgHHxwhjNOeQHwcrQ9l3JP2eRUKfr6fBpnMXYOXLF/NItzJu2rB3qSvBbeTDlk2mo97GekXbk7NKUOG8XHEpK7uT1kUFrSt80bJBCncfhvNRcDqVJ5c4MUyjloiz88sIeu+2GfgGT9BnC3NnIwxFpvaW4yRFmpUF6y0T78xamltFdbZykIWs1Tfa9pclzhZ/bl64mbfI/GzEQ6ddRF5xr1n5sN7zNostEOM/safnKwq6Af0ERMGmyv/66ge2YwB86J9xrKLozGvRXLKF2+pa48rezsfaKPmdc7UUuI9q+g0LPW0VFVVq56Py9W0tO1Hj9e3KWy859W1unfpAc3nZong5Kh5Z4G63GZNOWpZdd6dTq3RrXInCXWlWYJPUs97ttkspFaNsPzc9UdO73RpsMFSbUqmiw7seneKvvz1o7y/O5+XNNzR4my2//wDxip+0Ssmvsbdm3SijpNBF2KJE7NGl9fqWtHDR5tQeV/5gwoYZre7tLja6t/s+Wv4pW7vnC3tPpiKDeZNbu3Oftoke15NXkYUXAOeTti0dadC7+JTtK+zRiYH6NpXioshWyZ6COP9sg3+Jjrh4+9/XFPtzBcC6vVcutnHwyF+2HEWuP7MX5HRog6kH5uSoG2Rpbi/vgsxZmb1sPio7B07wcZKbIDfeEVo04vPoEcUKxMosmery+vhUnlktIVlyuvuzTOGbuPvLVfLV/w==</diagram></mxfile> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,14 +15,14 @@ A personal learning project using a connection to a [legacy event management sys | |
|
||
## More | ||
|
||
This is primarily a project for me to learn Go to establish and understand patterns for writing service and unit tests. It was used as the basis for a workshop that I first did in Todmorden in June 2022. | ||
This is primarily a project for me to learn Go to establish and understand patterns for writing service and unit tests. It was used as the basis for a workshop that I first did in Todmorden in June 2022 for [HacktionLab](https://hacktionlab.org). | ||
|
||
In the project I also attempt to use best practices around: | ||
|
||
* Test driven development using the Gomock library for unit tests | ||
* Behavioural driven development tests using Godock and feature files written in Gherkin | ||
* Test driven development using the stubs, spies and mocks library for unit tests, with extensive reworking to make the tests more refactor proof and test behaviour and not implementation, thanks to input from Hoegrammer. | ||
* Behavioural driven development tests using Godog with acceptance-test feature files written in Gherkin | ||
* Clean code - naming of methods, variables, tests, packages, etc. | ||
* SOLID (where possible given that Go is not an OO language) | ||
* SOLID (where possible given that Go is a little unusual as an OO language preferring, as it does, composition over inheritance) | ||
* Design patterns | ||
* Moduliarisation of Go code using packages | ||
* Infrastructure as code and devops approaches using Fabric and Terraform | ||
|
@@ -31,6 +31,10 @@ In the project I also attempt to use best practices around: | |
|
||
 | ||
|
||
### Entity Relationships | ||
|
||
 | ||
|
||
## Using CLAMS | ||
|
||
To use CLAMS, get the API Gateway endpoint via AWS Console; it's also displayed as the output of the deployment script (see below). There is an [example Postman collection](CLAMS.postman_collection.json) that you can use. The endpoints provided are: | ||
|
@@ -52,34 +56,43 @@ In the following test and deployment sections you'll need to create a pair of cr | |
There are three AWS Lambda functions: | ||
|
||
* [Attendee Writer](functions/attendee-writer) - Writes new incoming attendees into the DynamoDB datastore | ||
* [Attendee API](functions/attendees-api) - Presents the attendee's details to the world in JSON | ||
* [Report API](functions/report-api) - Does some calculations and presents data to the world in JSON | ||
* [Attendee API](functions/attendees-api) - Presents the attendee's details to the world and does some reporting in JSON | ||
* [Authorizer](functions/authorizer) - Provides HTTP Basic Auth access to certain endpoints (i.e. for PUT, POST, DELETE) | ||
|
||
## Shared packages | ||
|
||
As an example of shared packages, these Lambda functions all use the shared _attendee_ package located in [](attendee). This can be used in your own programs thus: | ||
As an example of a packages shared between multiple Lambda. The Lambda functions all use the shared _attendee_ and _awscfg_ packages located in the same parent directory as the Lambdas themselves. This can be used in your own programs along the lines of: | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/mikebharris/CLAMS/attendee" | ||
"github.com/mikebharris/CLAMS/functions/attendee" | ||
) | ||
|
||
func main() { | ||
awsConfig, _ := newAwsConfig("us-east-1") | ||
store := attendee.AttendeesStore{Db: dynamodb.NewFromConfig(*awsConfig), Table: "the-attendee-table"} | ||
attendees, _ := store.GetAllAttendees(context.Background()) | ||
for i, a := range attendees { | ||
fmt.Printf("Attendee number %d is known as %s\n", i, a.Name) | ||
a := attendee.Attendee{ | ||
AuthCode: "ABCDEF", | ||
Name: "Frank Ostrowski", | ||
Email: "[email protected]", | ||
Telephone: "0101 0101 01010", | ||
NumberOfKids: 0, | ||
Diet: "I eat BASIC code for lunch", | ||
Financials: attendee.Financials{AmountToPay: 10, AmountPaid: 10, AmountDue: 0}, | ||
ArrivalDay: "Wednesday", | ||
NumberOfNights: 4, | ||
StayingLate: "No", | ||
CreatedTime: time.Now(), | ||
} | ||
|
||
fmt.Println(a) | ||
} | ||
``` | ||
|
||
## Other files | ||
|
||
The Terraform configuration files are in the [](terraform) directory, the frontend (hastily built in Svelte) is built in [](frontend), and [](uploader) containw the utility, which can be called from within [BAMS](https://github.com/mikebharris/), to upload the latest group of attendees to SQS. | ||
The Terraform configuration files are in the [](terraform) directory, the frontend (hastily built in Svelte) is built in [](frontend), and [](uploader) contains a utility to upload the latest group of attendees to SQS. It can be run on the command line or called from within [BAMS](https://github.com/mikebharris/). | ||
|
||
# Running Tests | ||
|
||
|
@@ -153,3 +166,7 @@ Options: | |
|
||
* Write a better front-end | ||
* Add authentication to the API | ||
* Add Kitchen reporter utility | ||
* Add ability to write new attendees to database | ||
* Add ability to synch bi-directionally between BAMS and CLAMS | ||
* Add ability to handle GDPR Requests-for-Erasure (RfE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
functions/attendee-writer/service-tests/features/attendee-writer.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
@Regression | ||
Feature: Attendee Writer service processes results and updates Attendees datastore | ||
Feature: Attendee Writer service processes incoming records from BAMS and updates CLAMS | ||
|
||
@happy_path | ||
Scenario: The attendees datastore is kept up to date with the records in BAMS | ||
Scenario: New records from BAMS are added to CLAMS | ||
# New records are stored | ||
When the Attendee Writer is invoked with an attendee record from BAMS to be processed | ||
Then the attendee is added to the Attendees Datastore | ||
Then an attendee record is added to CLAMS | ||
|
||
# Existing records are updated | ||
Scenario: Records in CLAMS are updated with changes to records in BAMS | ||
When the Attendee Writer is invoked with an updated attendee record from BAMS to be processed | ||
Then the attendee is updated in the Attendees Datastore | ||
Then the attendee record is updated in CLAMS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.