Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] feat: Server SDK Diagrams + Generator Action #657

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/diagrams.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Generate PlantUML Diagrams
on:
pull_request:
paths:
- 'diagrams/**.puml'

permissions:
contents: write
jobs:
generate_plantuml:
runs-on: ubuntu-latest
name: Generate
steps:
- name: Checkout Source
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Get changed UML files
id: getfile
run: |
echo "::set-output name=files::$(git diff --name-only HEAD^ HEAD | grep .puml | xargs)"

- name: Generate SVG Diagrams
uses: holowinski/plantuml-github-action@main
with:
args: -v -tsvg "diagrams/**.puml" -o "../static/diagrams"

- name: Push Local Changes
uses: stefanzweifel/git-auto-commit-action@v4.1.2
with:
commit_message: "Generate SVG files for PlantUML diagrams"
64 changes: 64 additions & 0 deletions diagrams/config-manager.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
@startuml
'DevCycle Config Manager
group Config Manager
group Constructor/Initialization
start
if (options.UseRealtimeUpdates) then (yes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this option is named wrong here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more "human" here - but if we want to make it exact that works too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well either use words or use the name of the option if youre going to write it as options.Something

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to make it clear that the value is being pulled from the options passed into the initialization call - thoughts on how to better do that? Our options aren't named consistently

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are named consistently in most cases. Any case where they aren't should be fixed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact you said "most" means they aren't :P Plus - all server SDKs don't actually have this functionality enabled - so for the 1/1 for go - thoughts on using the options.EnableRealtimeUpdates ? or options.DisableRealtimeUpdates ? -
Go will be disabled by default - so will have Enabled as the option name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be named the same as the existing option in the other SDKs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and it should be enabled by default

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until we're confident in it with the test harness - it's going to be disabled by default - cc @jonathannorris

The other SDKs this is relevant to (server sdks) do not have a current option - do we want to match the client sdks?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we want it to match the client SDKs

:Start Config Consolidation Thread;
else (no)
endif
stop
end group

group Config Polling Thread
start
repeat :Polling Interval;
if (Polling Enabled) then (yes)
:Fetch Config;
if (Success) then (yes)
:Update Config;
:Send Config Updated Event to EventHandler;
else (no)
repeat :Retry Fetch;
repeat while (Retryable Error) is (yes) not (no)
:Return error to EventHandler;
kill
endif
else (no)
:Cancel Polling;
kill
endif
repeat while (Polling Enabled) is (yes)
stop
end group


group Config Consolidation Thread

while (Event Received)
switch (Event Type)
case ()
:New Config Available;
:Fetch Config with minimum Last-Modified timestamp;
case ()
:Config Updated;
if (SSE URL is different than existing?) then (yes)
:Disable SSE;
:Update SSE URL;
:Start SSE Connection;
else (no)
endif
case ()
:SSE Connection Error;
:Disable SSE;
:Start Polling Thread;
case ()
:SSE Connection Success;
:Disable Polling;
endswitch
endwhile
-[hidden]->
detach
end group
end group
@enduml
28 changes: 28 additions & 0 deletions diagrams/event-manager.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@startuml
'DevCycle Config Manager
group Event Manager
group Constructor/Initialization
start
if (options.DisableAutomaticEventLogging and options.DisableCustomEventLogging) then (yes)
end
else (no)
:Start Event Flush Thread;
endif
stop
end group

group Event Flush Thread
while (Event Received) is (not Flush Stop)
switch (Event Type)
case ()
:Flush Interval;
case ()
:Force Flush;
endswitch
:Flush Events;
endwhile (Flush Stop)
end
end group
end group

@enduml
66 changes: 66 additions & 0 deletions diagrams/server-sdk-initialization.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
@startuml
'DevCycle Server SDK Initialization Sequence Diagram
start
:new DevCycleClient(sdkKey, options);
group Constructor/Initialization
if (Valid Server SDK Key) then (yes)
if (options.UseLocalBucketing) then (yes)
fork
group Initialize Config Manager
:Initialize Config Manager;
end group
fork again
group Initialize Event Manager
:Initialize Event Manager;
end group
fork again
if (options.ConfigEventHandler exists) then (yes)
fork
group Initial Fetch Thread
:Fetch Initial Config;
if (Success) then (yes)
:Initialize Config;
else (no)
if (Retryable Error) then (yes)
:Retry Fetch;
else (no)
:return error to EventHandler;
endif
endif
:Send Initialized Event;
end group
end fork
else (no)
:Fetch Initial Config;
if (Success) then (yes)
:Initialize Config;
else (no)
if (Retryable Error) then (yes)
:Retry Fetch;
else (no)
:Throw error;
kill
endif
endif
endif
end fork
if (options.UseRealtimeUpdates) then (no)
:Start Config Polling Thread;
else (yes)
endif
else (no)
if (options.ConfigEventHandler exists) then (yes)
:Send Initialized Event;
else (no)
endif
endif
else (no)
:SDK Key Validation Failed;
:Throw error;
kill
endif
end group
:Return DevCycleClient;
stop

@enduml
12 changes: 12 additions & 0 deletions docs/sdk/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,15 @@ extremely low latency.
Cloud bucketing is required to use specific features such as (EdgeDB)[/extras/edgedb] and
(Feature Opt-In)[/extras/advanced-targeting/feature-opt-in]. If you aren't using these features, then Local Bucketing
is the recommended mode.

## Server SDK Diagrams

The following diagrams illustrate the initialization flow, and logical background processes created/managed by the SDKs.
### Initialization Flow
![Initialization Flow](/diagrams/server-sdk-initialization.svg)

### Config Manager
![Config Manager](/diagrams/config-manager.svg)

### Event Manager
![Event Manager](/diagrams/event-manager.svg)
74 changes: 74 additions & 0 deletions static/config-manager.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
138 changes: 138 additions & 0 deletions static/diagrams/config-manager.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions static/diagrams/event-manager.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
142 changes: 142 additions & 0 deletions static/diagrams/server-sdk-initialization.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading