Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
109 changes: 109 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: CI

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

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
rust-version: [stable, beta]

steps:
- uses: actions/checkout@v4

- name: Set up Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
components: rustfmt, clippy

- name: Cache Rust dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Check formatting
run: cargo fmt --all -- --check

- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Run unit tests
run: cargo test --lib

- name: Build binaries
run: cargo build --release

- name: Run integration tests
run: cargo test --test integration_test

build:
runs-on: ubuntu-latest
needs: test

strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-gnu

steps:
- uses: actions/checkout@v4

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Install cross-compilation tools
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
cargo install cross

- name: Build for ${{ matrix.target }}
run: |
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then
cargo build --release --target ${{ matrix.target }}
else
cross build --release --target ${{ matrix.target }}
fi

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: binaries-${{ matrix.target }}
path: target/${{ matrix.target }}/release/flare-*

docker:
runs-on: ubuntu-latest
needs: test

steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
run: |
docker build -t flare-tools:$(git describe --tags --dirty --always) .

- name: Test Docker image
run: |
docker run --rm flare-tools:$(git describe --tags --dirty --always) flare-admin --help
docker run --rm flare-tools:$(git describe --tags --dirty --always) flare-stats --help
92 changes: 92 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest

strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-gnu
- x86_64-apple-darwin
- aarch64-apple-darwin

steps:
- uses: actions/checkout@v4

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Get tag name
id: tag
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Install cross-compilation tools
run: |
cargo install cross

- name: Build for ${{ matrix.target }}
run: |
if [[ "${{ matrix.target }}" == *"darwin"* ]]; then
# For macOS targets, we need special handling
cross build --release --target ${{ matrix.target }}
elif [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then
cargo build --release --target ${{ matrix.target }}
else
cross build --release --target ${{ matrix.target }}
fi

- name: Create release archive
run: |
mkdir -p build/bin
cp target/${{ matrix.target }}/release/flare-admin build/bin/
cp target/${{ matrix.target }}/release/flare-stats build/bin/
cp target/${{ matrix.target }}/release/kubectl-flare build/bin/
cd build/bin
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
zip -r flare-tools-${{ steps.tag.outputs.TAG }}-${{ matrix.target }}.zip .
else
tar -czf flare-tools-${{ steps.tag.outputs.TAG }}-${{ matrix.target }}.tar.gz .
fi

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/bin/flare-tools-${{ steps.tag.outputs.TAG }}-${{ matrix.target }}.tar.gz
asset_name: flare-tools-${{ steps.tag.outputs.TAG }}-${{ matrix.target }}.tar.gz
asset_content_type: application/gzip

create_release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}

steps:
- uses: actions/checkout@v4

- name: Get tag name
id: tag
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Create Release
uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.TAG }}
release_name: Release ${{ steps.tag.outputs.TAG }}
draft: false
prerelease: false
35 changes: 35 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Goal
- Reimplement flare-tools from ruby to rust.
- Add kubectl flare command. It is a proxy command which runs flare-tools command on index server.
- Do unittest with a mock server.
- Do e2e test without a mock server.
- Use DNS names on e2e test.
- Test all commands on both tests.

# Flare-tools commands
- Flare-admin is the main command for flare-tools.
- The commands are as follows(See ./README.txt):
- flare-admin dumpkey [hostname:port] ...
- flare-admin master [hostname:port:balance:partition] ...
- flare-admin balance [hostname:port:balance] ...
- flare-admin down [hostname:port] ...
- flare-admin restore [hostname:port]
- flare-admin stats [hostname:port] ...
- flare-admin verify
- flare-admin remove [hostname:port] ...
- flare-admin dump [hostname:port] ...
- flare-admin threads [hostname:port]
- flare-admin slave [hostname:port:balance:partition] ...
- flare-admin list
- flare-admin down [hostname:port] ...
- flare-admin ping [hostname:port] ...
- flare-admin index
- flare-admin reconstruct [hostname:port] ...

# What is a flare?
- Flare is a memcached compatible server. (See memcached protocol from ./memacached.protocol.txt)
- Flared server is a data server.
- Flarei server is a monitoring server for failover.
- Flare has master and slave.
- Flare has shard system.
- The commands like master, slave and reconstruct calls flush_all command before the main command.
Loading
Loading