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

Pathfinder v1 #1

Merged
merged 25 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
13 changes: 13 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Stable rust 1.x on ARM64
FROM mcr.microsoft.com/devcontainers/rust:1-bullseye

# Additional nightly toolchain
RUN rustup toolchain install nightly

# Rust Components
RUN rustup component add --toolchain nightly rustfmt
RUN rustup component add clippy rustfmt
RUN cargo install cargo-expand

# Always use https for git as we're in a codespace
RUN git config --global url."https://github.com/".insteadOf ssh://git@github.com/
111 changes: 111 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"name": "Container",
"dockerComposeFile": "docker-compose.dev.yml",
"service": "app",
"shutdownAction": "stopCompose",
"workspaceFolder": "/workspace",
"remoteUser": "root",
"initializeCommand": "echo $(docker network ls | grep main > /dev/null || docker network create main)",
"forwardPorts": [
9092,
2181,
8081,
3001,
7559,
9021,
8883,
16686
],
"portsAttributes": {
"9092": {
"label": "Kafka"
},
"2181": {
"label": "Zookeeper"
},
"8081": {
"label": "Kafka Schema Registry"
},
"9021": {
"label": "Kafka Control Center"
},
"3001": {
"label": "RESTful API"
},
"7559": {
"label": "Redis"
},
"8883": {
"label": "MQTT (Mosquitto)"
},
"16686": {
"label": "Jaeger"
}
},
"customizations": {
"codespaces": {
"repositories": {
"jucr-io/schemas": {
"permissions": {
"contents": "read",
"packages": "read"
}
},
"jucr-io/lightning-rs": {
"permissions": {
"contents": "read",
"packages": "read"
}
}
}
},
"vscode": {
"extensions": [
"gruntfuggly.todo-tree",
"oderwat.indent-rainbow",
"bierner.markdown-mermaid",
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"nefrob.vscode-just-syntax"
],
"settings": {
"rust-analyzer.diagnostics.disabled": [
"trait-impl-incorrect-safety"
],
"rust-analyzer.references.excludeTests": true,
"rust-analyzer.cargo.allTargets": false,
"rust-analyzer.cargo.features": [
"create-kafka-topics"
],
"rust-analyzer.cargo.noDefaultFeatures": false,
"rust-analyzer.rustfmt.extraArgs": [
"+nightly"
],
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},
"editor.autoIndent": "full",
"editor.bracketPairColorization.enabled": true,
"editor.comments.insertSpace": true,
"editor.detectIndentation": true,
"markdown.preview.scrollEditorWithPreview": false,
"markdown.preview.scrollPreviewWithEditor": false,
"editor.dragAndDrop": false,
"editor.foldingImportsByDefault": false,
"editor.formatOnSave": true,
"editor.tabSize": 4,
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 2000,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"git.autofetch": "all",
"git.autofetchPeriod": 180,
"git.autorefresh": true,
"git.enableCommitSigning": true,
"indentRainbow.indicatorStyle": "light",
"indentRainbow.lightIndicatorStyleLineWidth": 1
}
}
}
}
129 changes: 129 additions & 0 deletions .devcontainer/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
version: "3.8"

services:

app:
build:
context: .
ports:
- 3001:3001
command: sleep infinity
depends_on:
- redis
- kafka-schema-registry
- kafka-broker
environment:
# Cargo
CARGO_NET_GIT_FETCH_WITH_CLI: true
# Tracing
TRACING__LOG_LEVEL: "info"
TRACING__LOG_FORMAT: "fmt"
TRACING__OTLP_ENDPOINT: "http://jaeger:4317"
# Basic Service
ROUTER_ENDPOINT__PORT: 3001
# Kafka
MESSAGE_CONSUMER__KAFKA__BROKERS: "kafka-broker:29092"
# Redis
KV_STORE__REDIS__HOST: "redis"
KV_STORE__REDIS__PORT: 7559
KV_STORE__REDIS__PASSWORD: "jucr12"
KV_STORE__REDIS__TLS_ENABLED: false
volumes:
- ..:/workspace:cached

jaeger:
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686"
- "4317:4317"
- "4318:4318"

kafka-broker:
image: confluentinc/cp-server:7.5.0
hostname: kafka-broker
container_name: kafka-broker
ports:
- "9092:9092"
- "9101:9101"
healthcheck:
# test: nc -z localhost 9092 || exit -1
test: "kafka-topics.sh --bootstrap-server 127.0.0.1:9092 --topic hc --create --if-not-exists && kafka-topics.sh --bootstrap-server 127.0.0.1:9092 --topic hc --describe"
start_period: 15s
interval: 5s
timeout: 10s
retries: 10
environment:
KAFKA_BROKER_ID: 1
KAFKA_NODE_ID: 1
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT'
KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://kafka-broker:29092,PLAINTEXT_HOST://localhost:9092'
KAFKA_METRIC_REPORTERS: io.confluent.metrics.reporter.ConfluentMetricsReporter
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_CONFLUENT_LICENSE_TOPIC_REPLICATION_FACTOR: 1
KAFKA_CONFLUENT_BALANCER_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_JMX_PORT: 9101
KAFKA_JMX_HOSTNAME: localhost
KAFKA_CONFLUENT_SCHEMA_REGISTRY_URL: http://schema-registry:8081
CONFLUENT_METRICS_REPORTER_BOOTSTRAP_SERVERS: kafka-broker:9092
CONFLUENT_METRICS_REPORTER_TOPIC_REPLICAS: 1
CONFLUENT_METRICS_ENABLE: 'true'
CONFLUENT_SUPPORT_CUSTOMER_ID: 'anonymous'
KAFKA_PROCESS_ROLES: 'broker,controller'
KAFKA_CONTROLLER_QUORUM_VOTERS: '1@kafka-broker:29093'
KAFKA_LISTENERS: 'PLAINTEXT://kafka-broker:29092,CONTROLLER://kafka-broker:29093,PLAINTEXT_HOST://0.0.0.0:9092'
KAFKA_INTER_BROKER_LISTENER_NAME: 'PLAINTEXT'
KAFKA_CONTROLLER_LISTENER_NAMES: 'CONTROLLER'
KAFKA_LOG_DIRS: '/tmp/kraft-combined-logs'
CLUSTER_ID: 'MkU3OEVBNTcwNTJENDM2Qk'
volumes:
- kafka-broker-data:/data

kafka-schema-registry:
image: confluentinc/cp-schema-registry:7.5.0
hostname: kafka-schema-registry
container_name: kafka-schema-registry
depends_on:
- kafka-broker
ports:
- "8081:8081"
environment:
SCHEMA_REGISTRY_HOST_NAME: kafka-schema-registry
SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: 'kafka-broker:29092'
SCHEMA_REGISTRY_LISTENERS: http://0.0.0.0:8081

kafka-control-center:
image: confluentinc/cp-enterprise-control-center:7.5.0
hostname: kafka-control-center
container_name: kafka-control-center
depends_on:
- kafka-broker
- kafka-schema-registry
ports:
- "9021:9021"
environment:
CONTROL_CENTER_BOOTSTRAP_SERVERS: 'kafka-broker:29092'
CONTROL_CENTER_SCHEMA_REGISTRY_URL: "http://kafka-schema-registry:8081"
CONTROL_CENTER_REPLICATION_FACTOR: 1
CONTROL_CENTER_INTERNAL_TOPICS_PARTITIONS: 1
CONTROL_CENTER_MONITORING_INTERCEPTOR_TOPIC_PARTITIONS: 1
CONFLUENT_METRICS_TOPIC_REPLICATION: 1
PORT: 9021

redis:
image: bitnami/redis:latest
environment:
REDIS_PASSWORD: "jucr12"
REDIS_PORT_NUMBER: "7559"
ports:
- 7559:7559

volumes:
kafka-broker-data:

networks:
default:
name: main
external: true
42 changes: 42 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: lint

on:
pull_request:

permissions:
contents: read
checks: write
statuses: write

jobs:
fmt:
uses: jucr-io/github-reusable-workflows/.github/workflows/rust-fmt-v1.yaml@main
secrets: inherit
with:
profile: "release"
toolchain: "nightly"
clippy:
uses: jucr-io/github-reusable-workflows/.github/workflows/rust-clippy-v1.yaml@main
secrets: inherit
strategy:
fail-fast: false
matrix:
profile: ["release"]
toolchain: ["stable"]
targets:
- name: "."
target: "x86_64-unknown-linux-gnu"
- name: "."
target: "aarch64-unknown-linux-gnu"
- name: "."
target: "aarch64-apple-darwin"
with:
profile: ${{ matrix.profile }}
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.targets.target }}
# features: ${{ matrix.targets.features }}
name: ${{ matrix.targets.name }}
rust_log: "debug"
rust_backtrace: "full"
rustflags: "-D warnings"
debug: "false"
74 changes: 74 additions & 0 deletions .github/workflows/publish-binaries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: publish-binaries

on:
release:
types: [released, prereleased]

permissions: write-all

jobs:
build:
name: ${{ matrix.platform.target }}
runs-on: ${{ matrix.platform.os }}
if: ${{ !startsWith(github.ref_name, 'v') }}
strategy:
fail-fast: false
matrix:
platform:
- os_name: Linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
bin: pathfinder
name: pathfinder-linux-x86_64-gnu.tar.gz

- os_name: Linux-aarch64-gnu
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
bin: pathfinder
name: pathfinder-linux-aarch64-gnu.tar.gz

- os_name: macOS-aarch64
os: macOS-latest
target: aarch64-apple-darwin
bin: pathfinder
name: pathfinder-apple-darwin-aarch64.tar.gz

steps:
- name: checkout
uses: actions/checkout@v4

- name: init cache
uses: Swatinem/rust-cache@v2

- name: setup toolchain
run: rustup toolchain install stable --profile minimal

- name: set version
run: cargo install cargo-edit && cargo set-version $VERSION
env:
VERSION: ${{ github.ref_name }}

- name: run build
uses: houseabsolute/actions-rust-cross@v0
with:
command: "build"
target: ${{ matrix.platform.target }}
toolchain: "stable"
args: "--locked --release"
strip: true

- name: package
shell: bash
run: |
cd target/${{ matrix.platform.target }}/release
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
else
tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
fi
cd -

- name: upload artifacts
uses: softprops/action-gh-release@v2
with:
files: "pathfinder-*"
Loading
Loading