Skip to content

Commit

Permalink
Promote 2.0 (#7)
Browse files Browse the repository at this point in the history
* 2.0 parser and grpc lib

* ping/pong, reflection, and config access in grpc

* serial block logic, basic conditional

* sample client

* fix parameters

* clean up in prep for 2.0

* update buildpath

* remove CI for now

* update alpine

* better error handling

* all grpcs can recover

* uuid prints and proper uuid generation

* parallel works

* conditional support

* better server/client integration

* python client

* update readme for 2.0

* remove javascript

* readme with details, default python name is hostname
  • Loading branch information
jrcichra authored Jul 9, 2021
1 parent 51c4c77 commit 6cc2c31
Show file tree
Hide file tree
Showing 67 changed files with 4,906 additions and 2,944 deletions.
58 changes: 29 additions & 29 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ name: "CodeQL"

on:
push:
branches: [ master ]
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches: [master]
schedule:
- cron: '16 10 * * 4'
- cron: "16 10 * * 4"

jobs:
analyze:
Expand All @@ -28,40 +28,40 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'go', 'javascript', 'python' ]
language: ["go", "python"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
33 changes: 2 additions & 31 deletions .github/workflows/karmen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/build-push-action@v2
with:
context: ./karmen
file: ./karmen/Dockerfile
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
Expand All @@ -75,32 +75,3 @@ jobs:
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ fromJson(steps.repo.outputs.result).license.spdx_id }}
CI:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Repo metadata
id: repo
uses: actions/github-script@v3
with:
script: |
const repo = await github.repos.get(context.repo)
return repo.data
- name: CI
run: |
set -x
# Build karmen
cd karmen
docker build -t jrcichra/karmen:ci .
cd ..
# Build the CI containers
cd ci
docker-compose build --build-arg GITHUB_SHA=${GITHUB_SHA}
# Run the CI test docker-compose
timeout 120 docker-compose up || /bin/true
# What did each container exit with
for i in $(docker ps -a | awk '{print $1}' | grep -v CONTAINER)
do
docker inspect $i --format='{{.State.ExitCode}}'
done
11 changes: 3 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
karmen-python-client/dist
karmen/controller
karmen-go-client/karmen-go-client
ci/go1/go1
karmen-node-client/node_modules/
ci/node1/node_modules/
ci/node1/yarn-error.log
karmen-node-client/yarn-error.log
a.out
goclient/a.out
pythonclient/__pycache__/
18 changes: 0 additions & 18 deletions .vscode/launch.json

This file was deleted.

4 changes: 2 additions & 2 deletions karmen/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM golang:alpine3.13 as firststage
FROM golang:alpine3.14 as firststage
WORKDIR /karmen
ADD . .
RUN go build -o karmen .
FROM alpine:3.13
FROM alpine:3.14
WORKDIR /karmen
COPY --from=firststage /karmen/karmen .
CMD ["./karmen"]
49 changes: 25 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,34 @@

Centralized Pub/Sub for microservices


# 2.0 release
+ I rewrote Karmen from the ground up in July 2021. It is incompatible with version 1.0.
## Enhancements
+ Karmen now runs off of gRPC, which cuts down lots of nasty bugs
+ `if:` as a key under an action is now a reserved word for conditional expressions
+ `parallel` and `serial` blocks should perform how you expect...each block is done serially
+ Context variables - actions can return parameters that are injected into a block-level state. These can be referenced in conditionals with `{hostname-action-variablename}`
+ I'll be converting the dashes to dots once I add that feature to the condition parser I used
+ For each action, the `{hostname-action-pass}` boolean is set automatically so you can conditionally run actions based on the result of previous actions without managing a parameter. Code 200 is defined as a `pass`
+ Action error handling is improved, currently returning HTTP-like codes. I may downgrade this to a boolean
## Bugs
+ Prone to crashes - if the clients aren't set up right or die, karmen may crash
+ In the meantime, please have the container `--restart=unless-stopped` or have a systemd service keep it up

## Get Started
### Using Karmen:
### Using Karmen (Server):
1. See [Docker Hub](https://github.com/jrcichra/karmen/releases) for releases
2. See [an example config](./example_config.yml) to start declaring your workflow
2. See [an example config](./example.yml) to start declaring your workflow
3. Run Karmen as part of your docker-compose.yml. see my [ example docker-compose.yml](./example_docker-compose.yml)
### Using Karmen's Python Client:
1. Install using `pip install karmen`
2. Usage example:
```python
import karmen

# Function that performs an action and returns a result
def hello(params,result):
print("Hello, world!")
result.Pass()
# Spawn a karmen client
k = karmen.Client()
# Register this client with the karmen server (based on hostname)
k.registerContainer()
# Register an event with the karmen server
k.registerEvent("docker_rocks")
# Register an action with the karmen server
k.registerAction("hello", hello)
# Emit an event called docker_rocks - this is declared in config.yml
k.emitEvent("docker_rocks")
```

### Clients with examples:
+ [Python](./pythonclient) - example in `karmen.py` when executed as script
+ [Golang](./goclient) - example in `main.go`
+ Or write your own! Karmen runs on gRPC. See existing implementations for reference
### Powered by
+ [gRPC](https://grpc.io/)
+ [Golang](https://golang.org/)
+ [Docker](https://www.docker.com/)
### Projects using Karmen
1. https://github.com/jrcichra/smartcar

Expand Down
17 changes: 0 additions & 17 deletions ci/ci_config.yml

This file was deleted.

35 changes: 0 additions & 35 deletions ci/docker-compose.yml

This file was deleted.

9 changes: 0 additions & 9 deletions ci/go1/Dockerfile

This file was deleted.

8 changes: 0 additions & 8 deletions ci/go1/go.mod

This file was deleted.

27 changes: 0 additions & 27 deletions ci/go1/go.sum

This file was deleted.

31 changes: 0 additions & 31 deletions ci/go1/go1.go

This file was deleted.

7 changes: 0 additions & 7 deletions ci/node1/Dockerfile

This file was deleted.

16 changes: 0 additions & 16 deletions ci/node1/node1.js

This file was deleted.

Loading

0 comments on commit 6cc2c31

Please sign in to comment.