Skip to content

Commit 1ec688d

Browse files
committed
Merge branch 'release/0.13.0'
2 parents 76b05c7 + bf7759b commit 1ec688d

File tree

71 files changed

+632
-340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+632
-340
lines changed

build.cake

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#tool "nuget:?package=GitVersion.CommandLine"
2-
#tool "nuget:?package=OpenCover"
2+
#tool "nuget:?package=OpenCover&version=4.6.832"
33
#tool "nuget:?package=ReportGenerator"
44
#tool "nuget:?package=GitReleaseNotes"
55
#addin "nuget:?package=Cake.DoInDirectory"
66
#addin "nuget:?package=Cake.Json"
77
#addin "nuget:?package=Newtonsoft.Json&version=9.0.1"
88
#tool "nuget:?package=xunit.runner.console"
99
#tool "nuget:?package=coveralls.net&version=0.7.0"
10-
#addin Cake.Coveralls
10+
#addin "nuget:?package=Cake.Coveralls"
11+
#addin "nuget:?package=Cake.Docker"
1112

1213
// compile
1314
var compileConfig = ValidateConfig(Argument("configuration", "Release"));
@@ -63,6 +64,14 @@ var tagsUrl = "https://api.github.com/repos/binarymash/evelyn/releases/tags/";
6364
var nugetFeedStableKey = EnvironmentVariable("nuget-apikey-stable");
6465
var nugetFeedStableUploadUrl = "https://www.nuget.org/api/v2/package";
6566
var nugetFeedStableSymbolsUploadUrl = "https://www.nuget.org/api/v2/package";
67+
68+
// docker compose
69+
var composeFiles = new[]
70+
{
71+
"./src/docker-compose.yml",
72+
"./src/docker-compose.override.yml"
73+
};
74+
6675
// internal build variables - don't change these.
6776
var releaseTag = "";
6877
GitVersion versioning = null;
@@ -347,6 +356,18 @@ Task("ReleasePackagesToStableFeed")
347356
Task("Release")
348357
.IsDependentOn("ReleasePackagesToStableFeed");
349358

359+
Task("RunSample")
360+
.Does(() =>
361+
{
362+
var settings = new DockerComposeUpSettings()
363+
{
364+
Build = true,
365+
Files = composeFiles,
366+
ForceRecreate = true
367+
};
368+
DockerComposeUp(settings);
369+
});
370+
350371
RunTarget(target);
351372

352373
private bool IsAuthoritativeBuild()

cake.config

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
; The configuration file for Cake.
2+
3+
[Nuget]
4+
Source=https://www.myget.org/F/binarymash-unstable/api/v2;https://api.nuget.org/v3/index.json
File renamed without changes.

docs/getting-started/running-the-client.rst

-87
This file was deleted.

docs/getting-started/running-the-server.rst

-89
This file was deleted.

docs/getting-started/running.rst

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Running Evelyn
2+
==============
3+
4+
The repository contains a sample server host and client application, and configuration for `Docker <https://www.docker.com/>`_ to run these using `EventStore <https://eventstore.org/>`_ as our event store. You can run these on the command line, or in Visual Studio.
5+
6+
Prerequisites
7+
-------------
8+
9+
- `Docker <https://www.docker.com/>`_ is installed on your computer. Note that if you're already running in a virtualised environment - for example, Windows running in Parallels on a Mac, then you probably can't use the docker files as Docker doesn't play nicely with nested virtualisation.
10+
11+
Running in Docker using the command line
12+
----------------------------------------
13+
14+
Run the ``./runSample.ps1`` script. This will kick off Cake scripts which will build and then run the Docker containers.
15+
16+
Running in Docker using Visual Studio
17+
-------------------------------------
18+
Ensure that the startup project is ``docker-compose``, then run the solution.

docs/getting-started/running-the-management-ui.rst docs/getting-started/using-the-management-ui.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Running the management UI
1+
Using the management UI
22
=========================
33

44
The Swagger UI is convenient for us as developers, but not particularly great for end users. Happily, Evelyn also has a management application that we can use to manage our toggles.

docs/getting-started/using.rst

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
Using Evelyn
2+
============
3+
4+
We'll assume that you've got the sample client and server running. Now let's try to do something with it.
5+
6+
Accessing the REST Server
7+
-------------------------
8+
9+
The Evelyn REST API endpoints are specified using `OpenAPI <https://www.openapis.org/>`_ and documented using using `Swagger UI <https://swagger.io/tools/swagger-ui/>`_. By default, the sample server host is configured to allow us to access port 2316, and so we can inspect the API in a browser by navigating to ``http://localhost:2316/swagger/``.
10+
11+
.. image:: ../images/swagger-1.png
12+
13+
If you don't see this, it might be because something else is already using port 2316. If this is the case, you'll need to modify the port forwarding configuration for evelyn-server-host in ``./src/docker-compose.yml`` to specify a different port.
14+
15+
When the server runs for the first time, it will set up a default account for us and add create some sample data to get us started. Lets check it is all set up correctly:
16+
17+
- In Swagger UI, expand the `GET /api/projects` section
18+
- Click the `Try it out` button
19+
- Click the `Execute` button
20+
21+
In Evelyn, a project is a logical collection of feature toggles and environments. The ``/api/projects`` endpoint returns us a list of all the projects on our account. When we click the `Execute` button, Swagger will make a call to this endpoint. The response should look something like this:
22+
23+
.. code-block:: json
24+
25+
{
26+
"accountId": "e70fd009-22c4-44e0-ab13-2b6edaf0bbdb",
27+
"projects": [
28+
{
29+
"id": "8f73d020-96c4-407e-8602-74fd4e2ed08b",
30+
"name": "My First Project"
31+
}
32+
],
33+
"created": "2018-05-27T15:58:13.6253741+00:00",
34+
"createdBy": "SystemUser",
35+
"lastModified": "2018-05-27T15:58:30.7611496+00:00",
36+
"lastModifiedBy": "SystemUser",
37+
"version": 1
38+
}
39+
40+
We can see here that our account ID is ``e70fd009-22c4-44e0-ab13-2b6edaf0bbdb``, and we have a project called ``My First Project`` which has the ID ``8f73d020-96c4-407e-8602-74fd4e2ed08b``.
41+
42+
Now we know the ID of the project, lets now get more details about it:
43+
44+
- Expand the `GET /api/projects/{id}` section
45+
- Click the `Try it out` button
46+
- In the `id` input box, enter the id of the project, ``8f73d020-96c4-407e-8602-74fd4e2ed08b``
47+
- Click the `Execute` button
48+
49+
The response should look something like this:
50+
51+
.. code-block:: json
52+
53+
{
54+
"id": "8f73d020-96c4-407e-8602-74fd4e2ed08b",
55+
"name": "My First Project",
56+
"environments": [
57+
{
58+
"key": "my-first-environment"
59+
}
60+
],
61+
"toggles": [
62+
{
63+
"key": "my-first-toggle",
64+
"name": "My First Toggle"
65+
}
66+
],
67+
"created": "2018-05-27T15:58:30.7715006+00:00",
68+
"createdBy": "SystemUser",
69+
"lastModified": "2018-05-27T15:58:30.8970043+00:00",
70+
"lastModifiedBy": "SystemUser",
71+
"version": 2
72+
}
73+
74+
We can see that the project has a single environment, ``my-first-environment`` and has one toggle, ``my-first-toggle``.
75+
76+
So far so good. Now lets turn our attention to the client.
77+
78+
79+
Using the Client
80+
----------------
81+
82+
An application that uses the Evelyn client must be configured to connect to the server to retrieve the current toggle states for a particular enviroment and project.
83+
84+
The sample client host is already configured to get the toggle state for the sample project and environment that was created when we started the server; you can find this configuration in ``.\src\Evelyn.Client.Host\Startup.cs``. Note that in this class we also start a background service, which is used to poll the server for the current state.
85+
86+
Now, take a look in the ``ClassWithToggle`` class. You'll see we're injecting an ``IEvelynClient`` in the constructor. This interface lets us access the toggle states for our chosen environment. We use the ``GetToggleState`` method on this interface to get the current state of our ``my-first-toggle`` toggle, and then use this to decide which block of code to execute.
87+
88+
Look at the logging output from sample - if you're using Visual Studio this will be in in the Output window, or if you're running on the command line it'll be directly in your shell. You should see something like this...
89+
90+
.. code-block:: text
91+
92+
This code is only called when the toggle is OFF.
93+
94+
It's clear from this that our execution path is currently that specified for when the toggle is turned off.
95+
96+
Changing toggle state
97+
---------------------
98+
99+
Now, lets change the state of our toggle. We can do this either through the Swagger UI or via the Evelyn Management UI (if you've set it up):
100+
101+
Changing toggle state in Swagger UI
102+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103+
104+
- Expand the `POST /api/projects/{projectId}/environments/{environmentKey}/toggles/{toggleKey}/change-state` section
105+
- Click the `Try it out` button
106+
- In the `projectId` input box, enter the id of the project, ``8f73d020-96c4-407e-8602-74fd4e2ed08b``
107+
- In the `environmentKey` input box, enter the key of our environment, ``my-first-environment``
108+
- In the ``toggleKey`` input box, enter the key of our toggle, ``my-first-toggle``
109+
- In the `message Body` input box, enter this:
110+
.. code-block:: json
111+
112+
{
113+
"expectedToggleStateVersion": 0,
114+
"state": "True"
115+
}
116+
- Click the `Execute` button
117+
118+
Changing toggle state in Evelyn Management UI
119+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
120+
121+
- From the dashboard, select `My First Project`
122+
- Select `my-first-environment` from the list of environments
123+
- Find `my-first-toggle` in the list of toggles, and click its icon to change the state from ``OFF`` to ``ON``
124+
125+
126+
Now look at the logs again....
127+
128+
.. code-block:: text
129+
130+
This code is only called when the toggle is OFF.
131+
Toggle state has changed.
132+
This code is only called when the toggle is ON.
133+
134+
Now, we're going through the other code block! So, in changing the toggle state, we've changed the behaviour of our application.
135+
136+

0 commit comments

Comments
 (0)