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

Package Reorganization #31

Merged
merged 6 commits into from
Oct 1, 2023
Merged
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
34 changes: 34 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### Scope of changes

[Brief Description of the Changes]

Fixes SC-XXXXX

### Type of change

- [ ] new feature
- [ ] bug fix
- [ ] documentation
- [ ] testing
- [ ] technical debt
- [ ] other (describe)

### Acceptance criteria

[Copy acceptance criteria checklist from story for reviewer, or add a brief acceptance criteria here]

### Definition of Done

- [ ] I have manually tested the change running it locally (having rebuilt all containers) or via unit tests
- [ ] I have added unit and/or integration tests that cover my changes
- [ ] I have added new test fixtures as needed to support added tests
- [ ] I have updated the dependencies list if necessary (including updating yarn.lock and/or go.sum)
- [ ] I have recompiled and included new protocol buffers to reflect changes I made if necessary
- [ ] Check this box if a reviewer can merge this pull request after approval (leave it unchecked if you want to do it yourself)
- [ ] I have notified the reviewer via Shortcut or Slack that this is ready for review
- [ ] Documented service configuration changes or created related devops stories

### Reviewer(s) checklist

- [ ] Any new user-facing content that has been added for this PR has been QA'ed to ensure correct grammar, spelling, and understandability.
- [ ] Are there any TODOs in this PR that should be turned into stories?
102 changes: 88 additions & 14 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ on:
push:
branches:
- main
- develop
- "v*"
tags:
- 'v*'
- "v*"
pull_request:

jobs:
Expand All @@ -13,40 +15,112 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: 1.21.x

- name: Install Staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest
run: go install honnef.co/go/tools/cmd/staticcheck@2023.1.3

- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Lint Go Code
run: staticcheck ./...

test:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
go-version: [1.20.x, 1.21.x]
env:
GOPATH: ${{ github.workspace }}/go
GOBIN: ${{ github.workspace }}/go/bin
GOTEST_GITHUB_ACTIONS: 1
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/rotationalio/honu
steps:
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: ${{ matrix.go-version }}

- name: Cache Speedup
uses: actions/cache@v3
with:
path: ${{ env.GOPATH }}/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: ${{ env.GOPATH }}/src/github.com/rotationalio/honu

- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Dependencies
run: go version
run: |
go version
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]

- name: Code Generation
run: go generate ./...

- name: Run Unit Tests
run: go test -v -coverprofile=coverage.txt -covermode=atomic --race ./...

- name: Upload Coverage report to CodeCov
uses: codecov/[email protected]
build:
name: Build
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/go
GOBIN: ${{ github.workspace }}/go/bin
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/rotationalio/honu
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x

- name: Cache Speedup
uses: actions/cache@v3
with:
path: ${{ env.GOPATH }}/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Checkout Code
uses: actions/checkout@v4
with:
path: ${{ env.GOPATH }}/src/github.com/rotationalio/honu

- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
# Make sure to add to GitHub secrets!
token: ${{secrets.CODECOV_TOKEN}}
file: ./coverage.txt
version: "23.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Dependencies
run: |
go version
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]

- name: Code Generation
run: go generate ./...

- name: Build
run: go build ./cmd/...
10 changes: 5 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: 1.21.x

- name: Import GPG key
id: import_gpg
Expand All @@ -27,11 +27,11 @@ jobs:
passphrase: ${{ secrets.PASSPHRASE }}

- name: Create Release
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
50 changes: 44 additions & 6 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,42 @@
project_name: honu
project_name: honudb
dist: dist
builds:
# This is a library so no binary compilation is required
- skip: true
# Define multiple builds as a yaml list, specify by a unique id
- id: "cmd-honudb-build"
dir: .
main: ./cmd/honudb
binary: honudb
flags:
- -v
ldflags: -s -w -X github.com/rotationalio/honu.GitVersion={{.Commit}} -X github.com/rotationalio/honu.BuildDate={{.Date}}
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64
goarm:
- "6"
ignore:
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64

mod_timestamp: '{{ .CommitTimestamp }}'

archives:
- id: "honudb-archive-tgz"
format: tar.gz
builds:
- "cmd-honudb-build"
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
wrap_in_directory: true
files:
- LICENSE
- README.md

# Publish the release on GitHub
release:
Expand All @@ -27,9 +61,13 @@ release:
# Footer for the release body.
footer: |
### About
Honu is (currently) an experimental project that adds global versioning and
replication semantics to an embedded database such as leveldb. If you're interested
in this project, please see https://geodistributed.systems for more.

Honu is distributed key-value store that is intended for large systems of replicas
that are distributed across the globe. Honu provides an eventually consistent
replication semantic that uses reinforcement learning to optimize replication to
lower both costs and the instances of stale reads and write forks. If you're
interested in this project, please see https://geodistributed.systems for more.

# If set to true, will not auto-publish the release.
disable: false

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2021, Rotational Labs, LLC
Copyright (c) 2021, Rotational Labs, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
[![Go Reference](https://pkg.go.dev/badge/github.com/rotationalio/honu.svg)](https://pkg.go.dev/github.com/rotationalio/honu)
[![Go Report Card](https://goreportcard.com/badge/github.com/rotationalio/honu)](https://goreportcard.com/report/github.com/rotationalio/honu)
![GitHub Actions CI](https://github.com/rotationalio/honu/actions/workflows/build.yaml/badge.svg?branch=main)
[![codecov](https://codecov.io/gh/rotationalio/honu/branch/main/graph/badge.svg?token=7RY96Cu5dx)](https://codecov.io/gh/rotationalio/honu)

**A library for embedded database replication**
**HonuDB is a replicated key-value store intended for large systems that are distributed globally. Although HonuDB uses an eventually consistent gossip protocol for replication, it uses reinforcement learning with multi-armed bandits to optimize replication. Adaptive consistency reduces costs (ingress and egress data transfer) as well as improves consistency by lowering the likelihood of stale reads or forked writes.**

## Benchmarks

Expand Down
52 changes: 52 additions & 0 deletions cmd/honudb/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package main

import (
"fmt"
"log"
"os"

"github.com/joho/godotenv"
"github.com/rotationalio/honu"
"github.com/rotationalio/honu/config"
"github.com/urfave/cli/v2"
)

func main() {
// If a dotenv file exists load it for configuration
godotenv.Load()

// Create HonuDB command line application
app := cli.NewApp()
app.Name = "honudb"
app.Version = honu.Version()
app.Usage = "run and manage a honudb replica service"
app.Flags = []cli.Flag{}
app.Commands = []*cli.Command{
{
Name: "serve",
Usage: "run the honu replica service",
Category: "server",
Action: serve,
Flags: []cli.Flag{},
},
}

if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}

//===========================================================================
// Server Commands
//===========================================================================

func serve(c *cli.Context) (err error) {
// Load the configuration from a file or from the environment.
var conf config.Config
if conf, err = config.New(); err != nil {
return cli.Exit(err, 1)
}

fmt.Println(conf)
return nil
}
4 changes: 2 additions & 2 deletions bench_test.go → db/bench_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package honu_test
package db_test

import (
"math/rand"
"crypto/rand"
"os"
"testing"

Expand Down
2 changes: 1 addition & 1 deletion dsn.go → db/dsn.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package honu
package db

import (
"errors"
Expand Down
33 changes: 33 additions & 0 deletions db/dsn_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package db_test

import (
"testing"

. "github.com/rotationalio/honu/db"
"github.com/stretchr/testify/require"
)

func TestDSNParsing(t *testing.T) {
cases := []struct {
uri string
dsn *DSN
}{
{"leveldb:///fixtures/db", &DSN{"leveldb", "fixtures/db"}},
{"sqlite3:///fixtures/db", &DSN{"sqlite3", "fixtures/db"}},
{"leveldb:////data/db", &DSN{"leveldb", "/data/db"}},
{"sqlite3:////data/db", &DSN{"sqlite3", "/data/db"}},
}

for _, tc := range cases {
dsn, err := ParseDSN(tc.uri)
require.NoError(t, err)
require.Equal(t, tc.dsn, dsn)
}

// Test error cases
_, err := ParseDSN("foo")
require.Error(t, err)

_, err = ParseDSN("foo://")
require.Error(t, err)
}
Loading
Loading