Skip to content

Commit c9fd86b

Browse files
committed
feat: initial skeleton
- Client and server packages, with helper scripts for local development. - API's for cache and strategies - Basic disk-backed LRU cache implementation - Linter config - CI config, includig release flow
1 parent 275cc4e commit c9fd86b

37 files changed

Lines changed: 1446 additions & 27 deletions

.github/workflows/ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
tags:
6+
- "v*.*.*"
7+
pull_request:
8+
name: CI
9+
jobs:
10+
formatted:
11+
name: Formatted
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: cashapp/activate-hermit@v1
16+
- run: |
17+
just fmt
18+
git diff
19+
test:
20+
name: Test
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: cashapp/activate-hermit@v1
25+
- name: Setup xattr-supported filesystem
26+
run: |
27+
mkdir -p /tmp/xattr-fs
28+
sudo mount -t tmpfs -o size=1G tmpfs /tmp/xattr-fs
29+
- name: Run tests
30+
run: just test
31+
env:
32+
TMPDIR: /tmp/xattr-fs
33+
lint:
34+
name: Lint
35+
runs-on: ubuntu-latest
36+
env:
37+
GOPROXY: direct
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: cashapp/activate-hermit@v1
41+
- run: just lint
42+
release:
43+
if: startsWith(github.ref, 'refs/tags/v')
44+
needs: ["test", "lint"]
45+
name: Release
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0
51+
- uses: cashapp/activate-hermit@v1
52+
- run: goreleaser release --fail-fast
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Added by goreleaser init:
2+
dist/

.golangci.yml

Lines changed: 466 additions & 0 deletions
Large diffs are not rendered by default.

.goreleaser.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
builds:
2+
- main: ./cmd/sfptc
3+
binary: sfptc
4+
id: sfptc
5+
env:
6+
- CGO_ENABLED=0
7+
goos:
8+
- linux
9+
- darwin
10+
goarch:
11+
- amd64
12+
- arm64
13+
- main: ./cmd/sfptcd
14+
id: sfptcd
15+
binary: sfptcd
16+
env:
17+
- CGO_ENABLED=0
18+
goos:
19+
- linux
20+
- darwin
21+
goarch:
22+
- amd64
23+
- arm64
24+
25+
archives:
26+
- format: tar.gz
27+
# this name template makes the OS and Arch compatible with the results of uname.
28+
name_template: >-
29+
{{ .ProjectName }}-
30+
{{- .Os }}-
31+
{{- .Arch }}
32+
format_overrides:
33+
- goos: windows
34+
format: zip
35+
checksum:
36+
name_template: "checksums.txt"
37+
snapshot:
38+
name_template: "{{ incpatch .Version }}-next"
39+
changelog:
40+
sort: asc
41+
filters:
42+
exclude:
43+
- "^docs:"
44+
- "^test:"
45+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
46+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

Justfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
_help:
2+
@just -l
3+
4+
# Run tests
5+
test:
6+
go test ./...
7+
8+
# Lint code
9+
lint:
10+
golangci-lint run
11+
12+
# Format code
13+
fmt:
14+
just --unstable --fmt
15+
golangci-lint fmt
16+
go mod tidy

README.md

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,32 @@
1-
# sfptc README
1+
# Super-fast Pass-through Cache (SFPTC)
22

3-
Congrats, project leads! You got a new project to grow!
3+
SFPTC is a server and tooling for incredibly efficient, protocol-aware caching. It is
4+
designed to be used at scale, with minimal impact on upstream systems. By "protocol-aware", we mean that the proxy isn't
5+
just a naive HTTP proxy, it is aware of the higher level protocol being proxied (Git, Docker, etc.) and can make more efficient decisions.
46

5-
This stub is meant to help you form a strong community around your work. It's yours to adapt, and may
6-
diverge from this initial structure. Just keep the files seeded in this repo, and the rest is yours to evolve!
7+
## Git
78

8-
## Introduction
9+
Git causes a number of problems for us, but the most obvious are:
910

10-
Orient users to the project here. This is a good place to start with an assumption
11-
that the user knows very little - so start with the Big Picture and show how this
12-
project fits into it.
11+
1. Rate limiting by service providers.
12+
2. `git clone` is very slow, even discounting network overhead
1313

14-
Then maybe a dive into what this project does.
14+
To solve this we apply two different strategies on the server:
1515

16-
Diagrams and other visuals are helpful here. Perhaps code snippets showing usage.
16+
1. Periodic full `.tar.zst` snapshots of the repository. These snapshots restore 4-5x faster than `git clone`.
17+
2. Passthrough caching of the packs returned by `POST /repo.git/git-upload-pack` to support incremental pulls.
1718

18-
Project leads should complete, alongside this `README`:
19-
* [CODEOWNERS](./CODEOWNERS) - set project lead(s)
20-
* [CONTRIBUTING.md](./CONTRIBUTING.md) - Fill out how to: install prereqs, build, test, run, access CI, chat, discuss, file issues
21-
* [Bug-report.md](.github/ISSUE_TEMPLATE/bug-report.md) - Fill out `Assignees` add codeowners @names
22-
* [config.yml](.github/ISSUE_TEMPLATE/config.yml) - remove "(/add your discord channel..)" and replace the url with your Discord channel if applicable
19+
On the client we redirect git to the proxy:
2320

24-
The other files in this template repo may be used as-is:
25-
* [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md)
26-
* [GOVERNANCE.md](./GOVERNANCE.md)
27-
* [LICENSE](./LICENSE)
21+
```ini
22+
[url "https://sfptc.local/github/"]
23+
insteadOf = https://github.com/
24+
```
2825

29-
## Project Resources
26+
As Git itself isn't aware of the snapshots, Git-specific code in the SFPTC CLI can be used to reconstruct a repository.
3027

31-
| Resource | Description |
32-
| ------------------------------------------ | ------------------------------------------------------------------------------ |
33-
| [CODEOWNERS](./CODEOWNERS) | Outlines the project lead(s) |
34-
| [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md) | Expected behavior for project contributors, promoting a welcoming environment |
35-
| [CONTRIBUTING.md](./CONTRIBUTING.md) | Developer guide to build, test, run, access CI, chat, discuss, file issues |
36-
| [GOVERNANCE.md](./GOVERNANCE.md) | Project governance |
37-
| [LICENSE](./LICENSE) | Apache License, Version 2.0 |
28+
## Docker
29+
30+
## Hermit
31+
32+
Hermit

bin/.go-1.25.5.pkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hermit

bin/.golangci-lint-2.7.2.pkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hermit

bin/.goreleaser-2.13.2.pkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hermit

bin/.just-1.45.0.pkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hermit

0 commit comments

Comments
 (0)