Skip to content

Commit

Permalink
Better developer experience
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriano Santos committed Aug 26, 2022
1 parent 68df251 commit 1037eb4
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 60 deletions.
66 changes: 60 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Contributing to eigr/massa
# Contributing to eigr/spawn

Thanks for contributing to eigr/massa!
Thanks for contributing to eigr/spawn!

Before continuing please read our [code of conduct][code-of-conduct] which all
contributors are expected to adhere to.

[code-of-conduct]: https://github.com/eigr-labs/spawn/blob/master/CODE_OF_CONDUCT.md
[code-of-conduct]: https://github.com/eigr/spawn/blob/master/CODE_OF_CONDUCT.md


## Contributing bug reports

If you have found a bug in eigr/massa please check to see if there is an open
If you have found a bug in eigr/spawn please check to see if there is an open
ticket for this problem on [our GitHub issue tracker][issues]. If you cannot
find an existing ticket for the bug please open a new one.

[issues]: https://github.com/eigr-labs/spawn/issues
[issues]: https://github.com/eigr/spawn/issues

A bug may be a technical problem such or a user experience issue such as
unclear or absent documentation. If you are unsure if your problem is a bug
Expand All @@ -23,7 +23,7 @@ please open a ticket and we will work it out together.

## Contributing code changes

Code changes to eigr/massa are welcomed via the process below.
Code changes to eigr/spawn are welcomed via the process below.

1. Find or open a GitHub issue relevant to the change you wish to make and
comment saying that you wish to work on this issue. If the change
Expand All @@ -36,3 +36,57 @@ Code changes to eigr/massa are welcomed via the process below.
work on. Depending on the change there may be multiple rounds of feedback.
4. Once the changes have been approved the code will be rebased into the
`main` branch.

# Development

This document describes the process for running and development this application on your local computer.

## Getting started

First of all you will need to have some tools installed on your computer:

1. Erlang/OTP 24 or newest.
2. Elixir 1.13 or newest.
3. Minikube, kind, K3s, or other Kubernetes flavor for local development.

After installing these tools, open Terminal and run the following:

```shell
git clone https://github.com/eigr/spawn.git
cd spawn
make
```

> **_NOTE:_** Compiling, test and building all applications and containers can take some time so this is the time when you stop and go have a delicious coffee **;-)**
There are many Make tasks to help during development for example to run the proxy locally via the elixir console there is a make task called ***run-proxy-local***, or to run all tests there is another called ***test***. Take a good look at the **Makefile** file to know all the tasks.

## Tour

The Spawn repository is divided into many directories and even though it is an Umbrella-type project it is also composed of many apps. Next, we will talk a little about the main directories and apps.

* **docs:** Where we try to keep important documents for understanding the platform.

* **config:** Where are all the default settings for the different applications that make up Spawn.

* **apps:** directory where the code of all the applications that are part of the Eigr Functions Spawn platform can be found. The applications are divided as follows:

* ***protos:*** Contains the protobuf files and compiled modules of the Spawn protocol.

* ***actors:*** This app concentrates all of the Spawn actors logic and is where a lot of the magic happens.

* ***proxy:*** This is the application that will act as a sidecar of the user functions. It contains the http server responsible for implementing the Spawn HTTP/Protobuf Protocol.

* ***statestores:*** Includes all data persistence logic and access to different databases and providers.

* ***operator:*** This is the Kubernetes Controller/Operator that controls the provisioning of the sidecars and user functions.

* ***metrics_endpoint:*** Helper library for exposing metrics in Prometheus format across applications.

* ***activator:*** It has the behaviors/contracts and implementation of the event handlers to be used by the different providers of the Activators.

* ***activator_´name´:*** Each application that starts with activator and follows the name of a given event provider implements in turn the connection logic and event management of that specific provider.

* **examples:** Where you can find some examples of using our CRDs and user applications.

**Don't forget to subscribe to our [Discord](https://discord.gg/2PcshvfS93) server and we wish you a good hack**.
3 changes: 2 additions & 1 deletion Dockerfile-operator
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ WORKDIR /home/app
COPY --from=builder /app/_build/prod/rel/bakeware .

RUN adduser app --disabled-password --home app
RUN mkdir -p app/.cache/bakeware
RUN chown -R app: /home/app

USER app
RUN mkdir -p app/.cache/bakeware

ENV MIX_ENV=prod

Expand Down
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ activator-sqs-image=${registry}/spawn-activator-sqs:${version}

.PHONY: all

all: build test build-all-images create-k8s-cluster create-k8s-namespace load-k8s-images generate-k8s-manifests apply-k8s-manifests
all: build test build-all-images

clean:
mix deps.clean --all

clean-all:
mix deps.clean --all && kind delete cluster --name kind-default
mix deps.clean --all && kind delete cluster --name default

build:
mix deps.get && mix compile
Expand All @@ -26,7 +26,7 @@ build-proxy-image:
docker build -f Dockerfile-proxy -t ${proxy-image} .

build-operator-image:
docker build -f Dockerfile-proxy -t ${operator-image} .
docker build -f Dockerfile-operator -t ${operator-image} .

build-all-images:
docker build -f Dockerfile-proxy -t ${proxy-image} .
Expand Down Expand Up @@ -77,5 +77,14 @@ create-k8s-namespace:
apply-k8s-manifests:
kubectl -n eigr-functions apply -f apps/operator/manifest.yaml

run:
run-proxy-local:
cd apps/proxy && PROXY_DATABASE_TYPE=mysql SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= iex --name [email protected] -S mix

run-operator-local:
cd apps/operator && MIX_ENV=dev iex --name [email protected] -S mix

run-proxy-image:
docker run --rm --name=spawn-proxy -e PROXY_DATABASE_TYPE=mysql -e SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= --net=host ${proxy-image}

run-operator-image:
docker run --rm --name=spawn-operator --net=host ${operator-image}
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ After that, just check your actors with:
kubectl get actornodes
```

## Project Development
## Local Development

Run:

Expand All @@ -509,4 +509,6 @@ Tests:

```shell
MIX_ENV=test PROXY_DATABASE_TYPE=mysql PROXY_HTTP_PORT=9001 SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= elixir --name [email protected] -S mix test
```
```

For more information on how to collaborate or even to get to know the project structure better, go to our [contributor guide](CONTRIBUTING.md)
42 changes: 0 additions & 42 deletions apps/operator/config/dev.exs

This file was deleted.

4 changes: 0 additions & 4 deletions apps/operator/config/prod.exs

This file was deleted.

2 changes: 2 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ config :proxy,
http_port: System.get_env("PROXY_HTTP_PORT", "9001") |> String.to_integer()

config :bonny,
get_conn: {K8s.Conn, :from_file, ["~/.kube/config", [context: "kind-default"]]},

# Add each CRD Controller module for this operator to load here
controllers: [
Operator.Controllers.V1.Activator,
Expand Down
Empty file removed deploy/Readme.md
Empty file.
Empty file removed deploy/k8s/deployment.yaml
Empty file.
1 change: 0 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ defmodule Spawn.MixProject do
operator: [
include_executables_for: [:unix],
applications: [operator: :permanent],
overlays: "apps/operator/config",
steps: [
:assemble,
&Bakeware.assemble/1
Expand Down

0 comments on commit 1037eb4

Please sign in to comment.