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

kubernetes support v0 #2

Merged
merged 145 commits into from
Jun 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
422489d
add k8s structure
DominicBurkart Sep 29, 2020
a7c208c
make declare async
DominicBurkart Sep 29, 2020
fcd2f51
add docker test framework for k8s
DominicBurkart Sep 29, 2020
5d8cfc0
use docker suite to run example tests, use rust suite for linting
DominicBurkart Sep 30, 2020
5bc2506
lints: make sure that subprojects are formatted correctly
DominicBurkart Sep 30, 2020
4544620
bug fix: make sure that distributed feature is actually being triggered
DominicBurkart Sep 30, 2020
a770b71
add k8s example structure
DominicBurkart Sep 30, 2020
daa3870
remove unimplemented service feature
DominicBurkart Sep 30, 2020
e2fbf29
bug fix: make sure that we only return cachable values from cached fu…
DominicBurkart Sep 30, 2020
ba9ce1b
don't make services use the distributed feature flag
DominicBurkart Sep 30, 2020
dffe67a
bug fix: add missing import
DominicBurkart Sep 30, 2020
d5e844e
update kubernetes tests
DominicBurkart Sep 30, 2020
912e01b
debug cached import error
DominicBurkart Oct 1, 2020
d5ebdf0
use has_declared instead of memoizing the declaration of a function o…
DominicBurkart Oct 5, 2020
281f732
lock the distribution_platform mutex once instead of thrice while dis…
DominicBurkart Oct 5, 2020
9508585
make platform mutable
DominicBurkart Oct 6, 2020
61a103c
implement setup_repo for k8s
DominicBurkart Oct 6, 2020
9af4be2
implement make_image for k8s
DominicBurkart Oct 7, 2020
8e7ded3
set up autoscale
DominicBurkart Oct 7, 2020
cdae75d
take en0 or eth0 interface (whichever comes first in interface list)
DominicBurkart Oct 7, 2020
b5c5ba1
update readme
DominicBurkart Oct 8, 2020
a839e35
impl drop for k8s
DominicBurkart Oct 8, 2020
d87a33d
get socket assigned from os instead of hoping 5000 is open
DominicBurkart Oct 8, 2020
e6badf9
add minimal docs to k8s
DominicBurkart Oct 8, 2020
b85e4e5
build project in container
DominicBurkart Oct 8, 2020
789c573
use cmd syntax instead of entrypoint syntax in dockerfile
DominicBurkart Oct 8, 2020
989be90
push image to repo in make_image instead of in a separate function
DominicBurkart Oct 8, 2020
d07ca01
implement dispatch
DominicBurkart Oct 8, 2020
6476b27
update names
DominicBurkart Oct 8, 2020
730ba0d
use relative path for local import definitions instead of absolute path
DominicBurkart Oct 8, 2020
05178af
fix misplaced comment
DominicBurkart Oct 8, 2020
c173215
update readme
DominicBurkart Oct 8, 2020
bf8b108
always build project and services with procmacro2_semver_exempt
DominicBurkart Oct 9, 2020
b63f691
don't hardcode dependency path while building
DominicBurkart Oct 9, 2020
7355acb
update docs
DominicBurkart Oct 14, 2020
7e15b49
correctly point to kind in k8s example script
DominicBurkart Oct 14, 2020
b80bbee
add more hooks to precommit
DominicBurkart Oct 14, 2020
7f77614
bug fix: tag images to localhost instead of using the network address
DominicBurkart Oct 16, 2020
a7c645e
use tokio runtime in examples because async-std seems not to work
DominicBurkart Oct 21, 2020
f631ef5
make examples exit with error codes if the output is not expected
DominicBurkart Oct 21, 2020
bab40ef
switch from surf to reqwest, and set up a reusable client for request…
DominicBurkart Oct 21, 2020
8d25e0d
do not export async-std, we use tokio now
DominicBurkart Oct 21, 2020
1a423f3
temp bugfix: for some reason, async traits don't seem to handle futur…
DominicBurkart Oct 21, 2020
38237d6
always use tokio 0.2 instead of 0.3
DominicBurkart Oct 21, 2020
7db9b2a
try using a handle to avoid the hanging issue from https://github.com…
DominicBurkart Oct 22, 2020
8746ed9
remove attempts at fixing hanging issue & inline dispatch GET request
DominicBurkart Oct 22, 2020
ee66f63
use patched kube dependency
DominicBurkart Oct 23, 2020
3eb4a4e
print before and after presumed error site
DominicBurkart Oct 23, 2020
9d06cdb
do not use patched kube, do use patched reqwest
DominicBurkart Oct 23, 2020
6296dad
remove unused import
DominicBurkart Oct 23, 2020
cbd8129
use tokio 0.2 instead of 0.3.1
DominicBurkart Oct 23, 2020
8e42ec0
use tokio delay_for fn in local_queue_example after registering a new…
DominicBurkart Oct 24, 2020
c3167d9
add debugging comments
DominicBurkart Oct 24, 2020
bc493c4
switch from tokio 0.2 to 0.3 with compat layer for 0.2 deps (kube and…
DominicBurkart Oct 26, 2020
49dffba
don't capture stdout in tests
DominicBurkart Oct 26, 2020
d6cc7a3
add debug comments
DominicBurkart Oct 26, 2020
93a895e
use tokio mutex because std sync mutex hangs on lock in our use case
DominicBurkart Oct 27, 2020
ea44eec
allow lint errors
DominicBurkart Oct 27, 2020
0f43e5b
make kind wait until the control pane reaches a ready status (or time…
DominicBurkart Oct 27, 2020
5f64b7a
update comment in kubernetes example
DominicBurkart Oct 27, 2020
b8538ce
alias kind
DominicBurkart Oct 28, 2020
af966ca
k8s: use default namespace
DominicBurkart Oct 28, 2020
7c0a5ea
change variable name
DominicBurkart Oct 28, 2020
8516277
add debug statements to kubernetes example
DominicBurkart Oct 28, 2020
6091eeb
install kubectl in k8s example environment
DominicBurkart Oct 28, 2020
5b6c3a7
add debug statements to kubernetes example
DominicBurkart Oct 28, 2020
663e56f
group installation commands in k8s dockerfile
DominicBurkart Oct 28, 2020
e712808
refactor CI and testing schema
DominicBurkart Oct 29, 2020
e5132b4
use a valid deployment name (only alphanumerics + '-')
DominicBurkart Oct 29, 2020
9b4d31a
use valid container name (only alphanumerics + '-')
DominicBurkart Oct 29, 2020
ca7573d
bug fix: ports accepts an array, not a map
DominicBurkart Oct 29, 2020
570cf57
dont specify invalid port protocol
DominicBurkart Oct 29, 2020
811c16a
use nodeport to expose service to network
DominicBurkart Oct 29, 2020
886ed0d
expose service to the device running each node
DominicBurkart Oct 30, 2020
8d5cb30
add script for running k8s tests locally
DominicBurkart Oct 30, 2020
306d117
refactor: don't try to set up a local registry
DominicBurkart Nov 2, 2020
7ddb8df
update CI to use new k8s testing scheme
DominicBurkart Nov 2, 2020
81989c1
switch to using microk8s in test env
DominicBurkart Nov 3, 2020
36d4605
switch from using alpine to ubuntu
DominicBurkart Nov 3, 2020
30f1593
consolidate rustup commands
DominicBurkart Nov 3, 2020
1476a67
include rust compiler deps
DominicBurkart Nov 3, 2020
476058a
set timezone in container to UTC
DominicBurkart Nov 4, 2020
59c55ed
add comments to generated dockerfile
DominicBurkart Nov 4, 2020
84264e9
build k8s version as debug when project is built in debug, and releas…
DominicBurkart Nov 4, 2020
c62847c
attempt to fix microk8s ci
DominicBurkart Nov 4, 2020
23c0bc8
compact rust nightly install command
DominicBurkart Nov 20, 2020
c48813e
add tracing
DominicBurkart Nov 24, 2020
b012cb8
don't include big binaries in traces
DominicBurkart Nov 25, 2020
7afab27
debug weird file DNE error
DominicBurkart Nov 24, 2020
c69638d
copy instead of symlinking a local dependency that is also an ancesto…
DominicBurkart Nov 30, 2020
03a7a48
fix service not exposing correctly
DominicBurkart Nov 30, 2020
d594601
wip: use ingress
DominicBurkart Feb 25, 2021
05ad5bc
debug bad gateway pt 1
DominicBurkart May 24, 2021
22b52b6
remove debug code causing service to return source path
DominicBurkart May 27, 2021
65f10cd
remove duplicate service creation command
DominicBurkart May 27, 2021
de757c7
check if changing ingress api version fixes ingress issue in ci
DominicBurkart May 28, 2021
c8a84d3
debug bad gateway using pod instead of deployment
DominicBurkart Jun 5, 2021
4dada05
fix binding to the wrong port in the app container
DominicBurkart Jun 5, 2021
f17e11b
use deployment instead of pod
DominicBurkart Jun 5, 2021
4c7f4a8
use stable API
DominicBurkart Jun 5, 2021
c39fcaa
don't send .turbolift files in project jars
DominicBurkart Jun 5, 2021
c7aaf75
Revert "use stable API"
DominicBurkart Jun 5, 2021
c2d2470
explicitly set pathType
DominicBurkart Jun 5, 2021
76f1305
at runtime, turbolift should generate a unique id per run
DominicBurkart Jun 5, 2021
94cc7c7
use networking.k8s.io/v1
DominicBurkart Jun 5, 2021
c08556b
extract ignored directories into a constant
DominicBurkart Jun 5, 2021
da9a9e9
try to do multi-stage builds
DominicBurkart Jun 6, 2021
9fcba7b
use app name when we need a unique identifier and use function name w…
DominicBurkart Jun 6, 2021
aab557b
install compiler tools for targeting a specific architecture
DominicBurkart Jun 6, 2021
cf98731
remove extraneous build
DominicBurkart Jun 6, 2021
c670126
don't follow target architecture path
DominicBurkart Jun 6, 2021
580dc1c
pass debug flag to install
DominicBurkart Jun 6, 2021
912d7bd
point ingress to service
DominicBurkart Jun 6, 2021
7df3a6e
add debug prints
DominicBurkart Jun 6, 2021
4b55ef3
remove unused service
DominicBurkart Jun 6, 2021
8fa5483
change path to services to line up with the path called by the client
DominicBurkart Jun 7, 2021
8aea326
delete debug print
DominicBurkart Jun 7, 2021
d392739
re-add service name into path
DominicBurkart Jun 7, 2021
785678f
add additional debug statements
DominicBurkart Jun 9, 2021
e326048
fix in-cluster url
DominicBurkart Jun 9, 2021
b246746
reformat service url to pass run id as a parameter
DominicBurkart Jun 11, 2021
71d3245
add function to make the container accessible from the cluster into t…
DominicBurkart Jun 12, 2021
3661832
refactor kubernetes test suite
DominicBurkart Jun 12, 2021
dade1e3
setup ingress in ci
DominicBurkart Jun 12, 2021
edadbc7
try increasing timeout for ingress
DominicBurkart Jun 12, 2021
a9608c3
Revert "try increasing timeout for ingress"
DominicBurkart Jun 12, 2021
b2ee4b0
add debug statements to debug ci ingress issue
DominicBurkart Jun 12, 2021
a0adf3f
add cluster instantiation and rename file from setup_ingress to setup…
DominicBurkart Jun 12, 2021
c11b79c
Revert "add debug statements to debug ci ingress issue"
DominicBurkart Jun 12, 2021
7626051
remove debug prints
DominicBurkart Jun 12, 2021
f665ce4
re-enable autoscale code
DominicBurkart Jun 12, 2021
b590ab7
consolidate related todo comments
DominicBurkart Jun 12, 2021
6fcd8ee
don't call ingress ips service ips
DominicBurkart Jun 12, 2021
f2b2aae
remove irrelevant, commented out code
DominicBurkart Jun 12, 2021
7f6d6a8
fix nightly version in local queue test
DominicBurkart Jun 13, 2021
cb19688
remove double import
DominicBurkart Jun 13, 2021
55c3502
reorder imports for clarity
DominicBurkart Jun 13, 2021
e1f1946
upgrade to version 0.1.1
DominicBurkart Jun 13, 2021
987eaf0
update readme
DominicBurkart Jun 13, 2021
34cd2da
cleanup all run resources when global state handler is dropped
DominicBurkart Jun 13, 2021
90c43ec
add todo to readme
DominicBurkart Jun 13, 2021
6a63d09
update example text
DominicBurkart Jun 13, 2021
1238ab7
update todos
DominicBurkart Jun 13, 2021
9163494
add keywords and categories
DominicBurkart Jun 13, 2021
1d418e7
add website badge to readme
DominicBurkart Jun 13, 2021
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
15 changes: 0 additions & 15 deletions .github/workflows/docker.yml

This file was deleted.

79 changes: 79 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: examples

on:
push:
branches: master
pull_request:
branches: [ master ]

jobs:
local_queue_example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: build local queue example
run: docker build -f examples/local_queue_example/Dockerfile .

kubernetes_example_local_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
path: './turbolift'
- name: install rustup and rust nightly
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly-2020-09-28
- name: run tests
run: |
cd turbolift/examples/kubernetes_example
RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo test -- --nocapture

kubernetes_example_local_run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
path: './turbolift'
- name: install rustup and rust nightly
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly-2020-09-28
- name: run tests
run: |
cd turbolift/examples/kubernetes_example
RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo run

kubernetes_example_distributed_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
path: './turbolift'
- name: install rustup and rust nightly
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly-2020-09-28
- uses: engineerd/setup-kind@v0.5.0
with:
version: "v0.11.0"
- name: run tests
run: |
cd turbolift/examples/kubernetes_example
sh setup_cluster.sh
RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo test --features distributed -- --nocapture

kubernetes_example_distributed_run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
path: './turbolift'
- name: install rustup and rust nightly
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly-2020-09-28
- uses: engineerd/setup-kind@v0.5.0
with:
version: "v0.11.0"
- name: run tests
run: |
cd turbolift/examples/kubernetes_example
sh setup_cluster.sh
RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo run --features distributed
18 changes: 9 additions & 9 deletions .github/workflows/rust.yml → .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: rust
name: linting

on:
push:
branches: [ master ]
branches: master
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always

jobs:
test:
lints:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -22,15 +22,15 @@ jobs:
override: true
- name: Rustup
run: rustup update
- name: Format
- name: Format turbolift
run: RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo fmt
- name: Format turbolift_internals
run: cd turbolift_internals && RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo fmt
- name: Format turbolift_macros
run: cd turbolift_macros && RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo
- name: Check without distributed feature
run: RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo check
- name: Check with distributed feature
run: RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo check --features "distributed"
run: RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo check --features distributed
- name: Clippy
run: RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo clippy -- -D warnings
- name: Local Queue without distributed feature
run: cd examples/local_queue_example && RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo test
- name: Local Queue with distributed feature
run: cd examples/local_queue_example && RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo test --features "distributed"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/target
target/
Cargo.lock
.turbolift/
.turbolift/
.idea
24 changes: 20 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
repos:
- repo: local
hooks:
- id: format
Expand All @@ -16,16 +17,31 @@
types: [rust]
pass_filenames: false
- id: check
name: Check
name: Cargo Check (local)
description: Runs `cargo check` on the repository.
entry: bash -c 'RUSTFLAGS='"'"'--cfg procmacro2_semver_exempt'"'"' cargo check "$@"' --
language: system
types: [ rust ]
pass_filenames: false
- id: check
name: Check
name: Cargo Check (distributed)
description: Runs `cargo check` on the repository with distributed flag
entry: bash -c 'RUSTFLAGS='"'"'--cfg procmacro2_semver_exempt'"'"' cargo check --features "distributed" "$@"' --
entry: bash -c 'RUSTFLAGS='"'"'--cfg procmacro2_semver_exempt'"'"' cargo check --features distributed "$@"' --
language: system
types: [ rust ]
pass_filenames: false
pass_filenames: false
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
- id: end-of-file-fixer
- id: detect-private-key
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 2.1.4
hooks:
- id: markdownlint
- id: shellcheck
20 changes: 12 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
[package]
name = "turbolift"
version = "0.1.0"
version = "0.1.1"
authors = ["Dominic Burkart <@DominicBurkart>"]
edition = "2018"
description = "WIP"
description = "Easy distribution interface"
keywords = ["distribution", "distributed", "kubernetes", "K8s"]
categories = ["build-utils", "development-tools", "concurrency", "network-programming", "asynchronous"]
readme = "README.md"
homepage = "https://dominic.computer/turbolift"
license = "Hippocratic-2.1"
repository = "https://github.com/dominicburkart/turbolift/"

[features]
distributed = ["chrono", "cached", "async-std"]
service = ["actix-web", "serde_json"]
distributed = ["chrono", "turbolift_macros/distributed"]
# todo we can optimize reqs for children with this load

[dependencies]
turbolift_macros = { path = "./turbolift_macros" }
turbolift_internals = { path = "./turbolift_internals" }
async-std = { version = "1.6", optional = true }
chrono = { version = "0.4", optional = true }
cached = { version = "0.19", optional = true }
actix-web = { version = "3", optional = true }
serde_json = { version = "1", optional = true }
actix-web = { version = "3" }
serde_json = { version = "1" }
tokio-compat-02 = { version = "0.1" }
tracing = {version="0.1", features=["attributes"]}
tracing-futures = "0.2.4"
101 changes: 63 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,89 @@
src="https://img.shields.io/crates/v/turbolift.svg"
alt="turbolift’s current version badge"
title="turbolift’s current version badge" />
[![status](https://github.com/DominicBurkart/turbolift/workflows/rust/badge.svg)](https://github.com/DominicBurkart/turbolift/actions?query=is%3Acompleted+branch%3Amaster+workflow%3A"rust")
[![status](https://github.com/DominicBurkart/turbolift/workflows/docker/badge.svg)](https://github.com/DominicBurkart/turbolift/actions?query=is%3Acompleted+branch%3Amaster+workflow%3A"docker")
[![status](https://img.shields.io/github/checks-status/dominicburkart/turbolift/master)](https://github.com/DominicBurkart/turbolift/actions?query=branch%3Amaster)
[![website](https://img.shields.io/badge/-website-blue)](https://dominic.computer/turbolift)

Turbolift is a WIP distribution platform for rust. It's designed to make distribution an afterthought
by extracting and distributing specific functions and their dependencies from a larger rust application.
Turbolift then acts as the glue between these extracted mini-apps and the main application.
Turbolift is a WIP distribution platform for rust. It's designed to make
distribution an afterthought by extracting and distributing specific
functions and their dependencies from a larger rust application.
Turbolift then acts as the glue between these extracted mini-apps and
the main application.

Look in the [examples](https://github.com/DominicBurkart/turbolift/tree/master/examples) directory for
full projects with working syntax examples.
Look in the [examples](https://github.com/DominicBurkart/turbolift/tree/master/examples)
directory for full projects with working syntax examples.

## Distribution as an afterthought.
Turbolift allows developers to turn normal rust functions into distributed services
just by tagging them with a macro. This lets you develop in a monorepo environment,
but benefit from the scalability of microservice architectures.
## Distribution as an afterthought

## Orchestration with a feature flag.
For quicker development builds, `cargo build` doesn't build the distributed version of your code by default.
Distribution is feature-gated so that it's easy to turn on (for example, in production), or off (for example,
while developing locally).
Turbolift allows developers to turn normal rust functions into distributed services
just by tagging them with a macro. Right now, Turbolift only works with K8s, though
it's designed to be extended to other cluster management utilities.

## Orchestration with a feature flag

Distribution is feature-gated in Turbolift, so it's easy to activate distribution
for some builds and deactivate it for others (while developing locally, for
example).

## Important implementation notes
- implemented over http using `reqwest` and `actix-web` (no current plans to refactor to use a lower level network protocol).
- assumes a secure network– function parameters are sent in plaintext to the microservice.
- source vulnerability: when building, anything in the project directory or in local dependencies
declared in the project manifest could be bundled and sent over the network to workers.

- implemented over http using `reqwest` and `actix-web` (no current plans to
refactor to use a lower level network protocol).
- assumes a secure network– function parameters are sent in plaintext to the
microservice.
- source vulnerability: when building, anything in the project directory or in
local dependencies declared in the project manifest could be bundled and sent
over the network to workers.

More information is available on the [project homepage](https://dominic.computer/turbolift).

## Current Limitations
- *Because of reliance on unstable proc_macro::Span features, all programs using turbolift need to
be built with an unstable nightly compiler flag (e.g. `RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo build`)* ([tracking issue](https://github.com/rust-lang/rust/issues/54725)).
- Functions are assumed to be pure (lacking side-effects such as
writing to the file system or mutation of a global variable).
*Today, this is not enforced by the code.*
- For a function to be distributed, its inputs and outputs have to be (de)serializable with [Serde](https://github.com/serde-rs/serde).

- DO NOT RUN TURBOLIFT ON A PUBLIC-FACING CLUSTER.
- *Because of reliance on unstable proc_macro::Span features, all programs
using turbolift need to be built with an unstable nightly compiler flag (e.g.
`RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo build`)*
([tracking issue](https://github.com/rust-lang/rust/issues/54725)).
- Functions are assumed to be pure (lacking side-effects such as
writing to the file system or mutation of a global variable).
*Today, this is not enforced by the code.*
- For a function to be distributed, its inputs and outputs have to be
(de)serializable with [Serde](https://github.com/serde-rs/serde).
- Distributed functions cannot be nested in other functions.
- Distributed functions cannot be methods.
- Distributed functions cannot use other functions called `main`.
- Distributed functions not in `main.rs` cannot use functions declared
- Distributed functions not in `main.rs` cannot use functions declared
in `main.rs`.
- Distributed functions cannot have `-> impl Trait` types.
- Unused functions that have been marked with the `on` macro will still be
compiled for distribution, even if eventually the linker will then
- Unused functions that have been marked with the `on` macro will still be
compiled for distribution, even if eventually the linker will then
remove the completed binary and distribution code.
- *Turbolift doesn't match the cargo compilation settings for microservices yet.*
- projects can have relative local dependencies listing in the cargo manifest, but those dependencies themselves
should not have relative local dependencies prone to breaking.
- if your program produces side effects when initialized, for example when
global constants are initialized, those side effects may be triggered
- projects can have relative local dependencies listing in the cargo
manifest, but those dependencies themselves should not have relative local
dependencies prone to breaking.
- if your program produces side effects when initialized, for example when
global constants are initialized, those side effects may be triggered
for each function call.
- turbolift runs functions on an unreproducible linux build, it doesn't
e.g. pin the env or match the OS of the current environment.

## Current Project Goals
- [ ] support kubernetes ([pr](https://github.com/DominicBurkart/turbolift/pull/2)).

- [X] support kubernetes ([pr](https://github.com/DominicBurkart/turbolift/pull/2)).
- [ ] implement liveliness and readiness checks for pods.
- [ ] while setting up a new service, wait for the pod to come alive via
readiness check instead of just sleeping ([code location](https://github.com/DominicBurkart/turbolift/blob/6a63d09afcd6e7234e62bcb797d31730cf49aacf/turbolift_internals/src/kubernetes.rs#L257)).
- [ ] roadmap support for other targets.
- [X] only use distributed configuration when flagged (like in `cargo build --features "distributed"`). Otherwise,
just transform the tagged function into an async function (to provide an identical API), but don't
build any microservices or alter any code.
- [ ] build cross-architecture compilation tests into the CI (RN we only test via github actions read Docker, and a different custom Docker test workflow)
- [X] only use distributed configuration when flagged (like in
`cargo build --features "distributed"`). Otherwise, just transform the
tagged function into an async function (to provide an identical API), but
don't build any microservices or alter any code.
- [ ] build cross-architecture compilation tests into the CI.

## Current tech debt todo

- [ ] start reducing ginormous API, right now basically everything is public
- [ ] refactor split between turbolift_internals and turbolift_macros
- [ ] improve names
- [ ] send params in json as payload instead of directly in the url
- [ ] we need to do a better job of cleaning up docker images, locally and in the cluster.
22 changes: 22 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Turbolift Examples

## Kubernetes

Builds a deployment, service, and ingress rule for the function to be
distributed. Cool features: distribution-as-a-feature, automatically deleting
the pods, deployments, services, and ingress rule when the main program
completes. This implementation is BYOC (Bring Your Own Container, you have to
pass a special function while instantiating the cluster interface that allows
makes the containers available in the cluster, perhaps via a private registry).

## Local Queue

The local queue example should never be used in a production application. It's
designed to test the core features of turbolift (automatically extracting
microservices from a rust codebase and running them on an http server), without
any of the platform-specific code for e.g. running on kubernetes. Check this
example out if you're interested in a bare-bones example turbolift project
without any platform-specific specialization. Note: if you're looking to run
code locally in turbolift instead of using a distribution platform, you should
deactivate the distributed turbolift feature in your project's `Cargo.toml`.
This will let your program run all services locally, e.g. while developing.
22 changes: 22 additions & 0 deletions examples/kubernetes_example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "kubernetes_example"
version = "0.1.0"
authors = ["Dominic Burkart <1351120+DominicBurkart@users.noreply.github.com>"]
edition = "2018"

[features]
"distributed" = ["turbolift/distributed"]

[dependencies]
rand = "0.7"
tokio = {version="1", features=["full"]}
lazy_static = "1"
futures = "0.3"
cute = "0.3"
anyhow = "1.0.41"
turbolift = { path="../../" }

# for printing out tracing
tracing = "0.1"
tracing-futures = "0.2"
tracing-subscriber = {version="0.2", features=["fmt"]}
Loading