Skip to content

Commit

Permalink
New sample app for JakartaEE
Browse files Browse the repository at this point in the history
  • Loading branch information
PanosNB committed Jul 17, 2023
1 parent a08a919 commit 16c65d7
Show file tree
Hide file tree
Showing 13 changed files with 786 additions and 11 deletions.
22 changes: 11 additions & 11 deletions design.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
# raygun4java design concerns

At its core, at its simplest, raygun4java the is `RaygunClient` - an object that holds state about a process and makes an http call to send the data to the raygun API.
At its core, raygun4java exposes `RaygunClient` - an object that holds state about a process and makes an HTTP call to send the data to the raygun API.

On the whole, the implementation of `RaygunClient` has not changed significantly over time. The majority of the work put into raygun4java is not in the `RaygunClient` but in the scaffolding used to create a `RaygunClient` instance.

## RaygunClient
An instance will collect data about the running process/thread/request and when given an error (exception + metadata), will sent that data to the Raygun API.
An instance will collect data about the running process/thread/request and when given an error (exception + metadata), will send that data to the Raygun API.

Before an error is sent to the Raygun API, it will pass through a series of filters (Raygun or user provided), any one of which could modify the error or even reject the send request.
Before an error is sent to the Raygun API, it will pass through a series of filters (Raygun or user provided), any could modify the error or even reject the send request.

After the sending of the error, it will pass through a series of handlers (Raygun or user provided) to perform required post send actions.

This filtering chain really is all there is to it. Should be the only place were logic changes are made and all effort should be made to fit this pattern.
This filtering chain really is all there is to it: It should be the only place were logic changes are made and all effort should be made to fit this pattern.

# Factories

In theory, developers are free to create their own `RaygunClient` instances whenever and however they like. In practice this is mostly an undesirable anti-pattern.
In theory, developers are free to create their own `RaygunClient` instances whenever and however they like. In practice, this is mostly an undesirable antipattern.

Using the factory pattern allows for the custom configuration of the `RaygunClient` during a application setup phase and then the effortless construction of a `RaygunClient` at the logical start of a process/thread/request which out the need for complex in-process configuration.
Using the factory pattern allows for the custom configuration of the `RaygunClient` during an application's setup phase and then the effortless construction of a `RaygunClient` at the logical start of a process/thread/request, which is needed for complex in-process configuration.

## RaygunClientFactory

The `RaygunClientFactory`, once configured will create a new `RaygunClient` on each call to `newClient()`, which should be used until the logical end of processing.

As mentioned each `RaygunClient` is configured with a filtering chain, which is set by the factory.
As mentioned, each `RaygunClient` is configured with a filtering chain, which is set by the factory.

The `RaygunClientFactory` can be configured to create `RaygunClient` instances will the desired filter chain using the `.withBeforeSend` and `.withAfterSend` builder functions.
The `RaygunClientFactory` can be configured to create `RaygunClient` instances, which apply the desired filter chain using the `.withBeforeSend` and `.withAfterSend` builder functions.

It is important to note that since each `RaygunClient` instance is independent from the other, it is also important that the filter chain is also independent - it is extrememly important that no data leaks between clients or filter instances.
Since each `RaygunClient` instance is independent, the filter chain is also independent: thus, no data leaks between clients or filter instances should occur.

## IRaygunSendEventFactory

To accomodate this water tightness, filter instances (`IRaygunSendEvent` ie `IRaygunOnBeforeSend` or `IRaygunOnAfterSend`) are not set onto the `RaygunClientFactory`, rather **filter factories** (`IRaygunSendEventFactory`) are set on the `RaygunClientFactory`.
To accommodate the required isolation, filter instances (`IRaygunSendEvent` ie `IRaygunOnBeforeSend` or `IRaygunOnAfterSend`) are not set onto the `RaygunClientFactory`, rather **filter factories** (`IRaygunSendEventFactory`) are set on the `RaygunClientFactory`.

When a call to `newClient()` is made on the `RaygunClientFactory`, the factory calls the `.create()` method on each of the filter factories (`IRaygunSendEventFactory`) to create instances of the filter (`IRaygunSendEvent` ie `IRaygunOnBeforeSend` or `IRaygunOnAfterSend`) (note: some filter factories might not return an *actual* new instance, if the filter does not maintain any state then its logically ok to return a shared instance - its up to the factory to choose)
When a call to `newClient()` is made on the `RaygunClientFactory`, the factory calls the `.create()` method on each of the filter factories (`IRaygunSendEventFactory`) to create instances of the filter (`IRaygunSendEvent` i.e., `IRaygunOnBeforeSend` or `IRaygunOnAfterSend`) (note: some filter factories might not return an *actual* new instance, if the filter does not maintain any state then it is logically ok to return a shared instance - it is up to the factory to choose)

This ensures a clean separation of instances.
38 changes: 38 additions & 0 deletions sampleJakartaEEApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
Binary file added sampleJakartaEEApp/.mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions sampleJakartaEEApp/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
Loading

0 comments on commit 16c65d7

Please sign in to comment.