This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Integrate Plank into Transport as a module #15
Merged
Merged
Conversation
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
jooskim
changed the title
Move Plank from personal repo
Integrate Plank into Transport as a module
Aug 3, 2021
Codecov Report
@@ Coverage Diff @@
## main #15 +/- ##
==========================================
+ Coverage 97.31% 97.34% +0.02%
==========================================
Files 28 28
Lines 1785 1805 +20
==========================================
+ Hits 1737 1757 +20
Misses 48 48
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
jooskim
force-pushed
the
topic/kjosh/plank
branch
5 times, most recently
from
August 3, 2021 21:53
61757cf
to
7e200aa
Compare
jooskim
force-pushed
the
topic/kjosh/plank
branch
4 times, most recently
from
August 6, 2021 17:37
14bdbbe
to
5e1cd47
Compare
Signed-off-by: Josh Kim <[email protected]>
Signed-off-by: Josh Kim <[email protected]>
Signed-off-by: Josh Kim <[email protected]>
Signed-off-by: Josh Kim <[email protected]>
Signed-off-by: Josh Kim <[email protected]>
Current implementation of REST bridge override had some critical issues that could lead to memory leaks and new URIs not being properly reflected or old URIs still accessible. These issues mostly originate from mux.Router not allowing full CRUD operations on the Router instance. (e.g. there was no way to effecively remove an existing route from any given router) Signed-off-by: Josh Kim <[email protected]>
jooskim
force-pushed
the
topic/kjosh/plank
branch
from
August 9, 2021 21:10
249d428
to
80a63fa
Compare
Signed-off-by: Josh Kim <[email protected]>
jooskim
force-pushed
the
topic/kjosh/plank
branch
from
August 10, 2021 18:53
80a63fa
to
9016768
Compare
Signed-off-by: Josh Kim <[email protected]>
daveshanley
suggested changes
Aug 10, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't wait to use this, most comments are nits around not having enough comments. Adding in docs is super important.
Signed-off-by: Josh Kim <[email protected]>
Signed-off-by: Josh Kim <[email protected]>
Signed-off-by: Josh Kim <[email protected]>
Both instances are initialized way before StartServer() is called, initialize() for example. Signed-off-by: Josh Kim <[email protected]>
jooskim
force-pushed
the
topic/kjosh/plank
branch
from
August 11, 2021 02:23
0342695
to
ee7dc31
Compare
jooskim
force-pushed
the
topic/kjosh/plank
branch
4 times, most recently
from
August 14, 2021 16:55
b3ac16d
to
a2f385b
Compare
Closes vmware-archive#19 Signed-off-by: Josh Kim <[email protected]>
Signed-off-by: Josh Kim <[email protected]>
Signed-off-by: Josh Kim <[email protected]>
Signed-off-by: Josh Kim <[email protected]>
Signed-off-by: Josh Kim <[email protected]>
These two structs are essential in notifying services about session disconnection hence opening the minimal structure for external packages to consume. Signed-off-by: Josh Kim <[email protected]>
Signed-off-by: Josh Kim <[email protected]>
Signed-off-by: Josh Kim <[email protected]>
Signed-off-by: Josh Kim <[email protected]>
jooskim
force-pushed
the
topic/kjosh/plank
branch
from
August 16, 2021 04:37
a2f385b
to
ba0937d
Compare
Signed-off-by: Josh Kim <[email protected]>
daveshanley
reviewed
Aug 16, 2021
daveshanley
reviewed
Aug 16, 2021
daveshanley
reviewed
Aug 16, 2021
daveshanley
reviewed
Aug 16, 2021
daveshanley
reviewed
Aug 16, 2021
daveshanley
reviewed
Aug 16, 2021
daveshanley
reviewed
Aug 16, 2021
Signed-off-by: Josh Kim <[email protected]>
Signed-off-by: Josh Kim <[email protected]>
This looks ready to me! Top work @jooskim, such an amazing new capability. |
daveshanley
approved these changes
Aug 16, 2021
Closes vmware-archive#18 Signed-off-by: Josh Kim <[email protected]>
jooskim
force-pushed
the
topic/kjosh/plank
branch
from
August 16, 2021 21:10
e62d15d
to
516ed24
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Plank
What is Plank?
Plank is a small yet powerful Golang server that can serve static contents, single page applications, create and expose
microservices over REST endpoints or WebSocket via a built-in STOMP broker, or even interact directly with other message brokers such as
RabbitMQ. All this is done in a consistent and easy to follow manner powered by Transport Event Bus.
Writing a service for a Plank server is in a way similar to writing a Spring Boot
Component
orService
, because a lot of tediousplumbing work is already done for you such as creating an instance and wiring it up with HTTP endpoints using routers etc.
Just by following the API you can easily stand up a service, apply any kinds of middleware your application logic calls for, and do all these
dynamically while in runtime, meaning you can conditionally apply a filter for certain REST endpoints, stand up a new service on demand, or
even spawn yet another whole new instance of Plank server at a different endpoint.
All of the features are cleanly exposed as public API and modules and, combined with the power of Golang's concurrency model using channels,
the Transport Event Bus allows creating a clean application architecture, with straightforward and easy to follow logic.
Detailed tutorials and examples are currently under work and will be made public on the Transport GitHub page.
Some of the topics that will initially be covered are:
Hello world
How to build
First things first, you'll need the latest Golang version. Plank was first written in Golang 1.13 and it still works with it, but it's advised
to use the latest Golang (especially 1.16 and forward) because of some nice new packages such as
embed
that we may later employ as part of Plank codebase.Once you have the latest Golang ready, follow the commands below:
Once successfully built,
plank
binary will be ready underbuild/
.Generate a self signed certificate
Plank can run in non-HTTPS mode but it's generally a good idea to always do development in a similar environment where you'll be serving your
audience in public internet (or even intranet). Plank repository comes with a handy utility script that can generate a pair of server certificate
and its matching private key at
scripts/create-selfsigned-cert.sh
. Simply run it in a POSIX shell like below. (requiresopenssl
libraryto be available):
The real Hello World part
Now we're ready to start the application. To kick off the server using the demo app you have built above, type the following and you'll see something like this:
Open your browser and navigate to https://localhost:30080, accept the self-signed certificate warning and you'll be greeted with a 404!
This is an expected behavior, as the demo app does not serve anything at root
/
, but we will consider changing the default 404 screen tosomething that looks more informational or more appealing at least.
All supported flags and usages
$PLANK_HOSTNAME
environment variable$PLANK_PORT
environment variable$PLANK_ROOT
environment variableExamples are as follows:
Advanced topics (WIP. Coming soon)
OAuth2 Client
Plank supports seamless out of the box OAuth 2.0 client that support a few OAuth flows. such as authorization
code grant for web applications and client credentials grant for server-to-server applications.
See below for a detailed guide for each flow.
Authorization Code flow
You'll choose this authentication flow when the Plank server acts as an intermediary that exchanges
the authorization code returned from the authorization server for an access token. During this process you will be
redirected to the identity provider's page like Google where you are asked to confirm the type of 3rd party application and
its scope of actions it will perform on your behalf and will be taken back to the application after successful authorization.
Client Credentials flow
You'll choose this authentication flow when the Plank server needs to directly communicate with another backend service.
This will not require user's consent like you would be redirected to Google's page where you confirm the type of application
requesting your consent for the scope of actions it will perform on your behalf. not requiring any interactions from the user. You will need to
create an OAuth 2.0 Client with
client_credentials
grant before following the steps below to implement theauthentication flow.