Skip to content

Commit

Permalink
rename memberlist to kv
Browse files Browse the repository at this point in the history
  • Loading branch information
asim committed Sep 16, 2022
1 parent dbb93a9 commit 7c7ac6d
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 11 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: release

on:
push:
branches-ignore:
- '**'
tags:
- 'v*.*.*'

jobs:
release:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@master
-
name: Fetch tags
run: git fetch --prune --unshallow --tags -f
-
name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.18
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Run tests
on: [push]

jobs:

test:
name: Test repo
runs-on: ubuntu-latest
steps:
- name: Install Protoc
uses: arduino/setup-protoc@v1
- name: Set up Go 1.18
uses: actions/setup-go@v1
with:
go-version: 1.18
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Enable caching
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Run tests
id: tests
env:
IN_TRAVIS_CI: yes
run: go test -v ./...
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kv
55 changes: 55 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
project_name: kv
release:
github:
owner: asim
name: kv
name_template: 'Release {{.Tag}}'
before:
hooks:
- go mod download
builds:
- binary: kv
env:
- CGO_ENABLED=0
- GO111MODULE=on
goos:
- linux
- darwin
- windows
goarch:
- 386
- amd64
- arm
- arm64
goarm:
- 7
ignore:
- goos: windows
goarch: arm64
archives:
- name_template: '{{.ProjectName}}-{{.Tag}}-{{.Os}}-{{.Arch}}{{if .Arm}}{{.Arm}}{{end}}'
replacements:
darwin: darwin
linux: linux
windows: windows
amd64: amd64
arm: arm
arm64: arm64
format: tar.gz
format_overrides:
- goos: windows
format: zip
files:
- LICENSE
- README.md
checksum:
name_template: 'checksums.txt'
algorithm: sha256
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ go get github.com/asim/kv

```shell
kv
-members="": comma seperated list of members
-nodes="": comma seperated list of nodes
-port=4001: http port
```

Expand All @@ -23,21 +23,21 @@ Start first node
kv
```

Make a note of the local member address
Make a note of the local node address
```
Local member 192.168.1.64:60496
Local node 192.168.1.64:60496
Listening on :4001
```

Start second node with first node as part of the member list
Start second node with first node as part of the nodes list
```shell
kv --members=192.168.1.64:60496 --port=4002
kv --nodes=192.168.1.64:60496 --port=4002
```

You should see the output
```
2015/10/17 22:13:49 [DEBUG] memberlist: Initiating push/pull sync with: 192.168.1.64:60496
Local member 192.168.1.64:60499
Local node 192.168.1.64:60499
Listening on :4002
```

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/asim/memberlist
module github.com/asim/kv

go 1.18

Expand Down
8 changes: 4 additions & 4 deletions memberlist.go → kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

var (
mtx sync.RWMutex
members = flag.String("members", "", "comma seperated list of members")
nodes = flag.String("nodes", "", "comma seperated list of nodes")
port = flag.Int("port", 4001, "http port")
items = map[string]string{}
broadcasts *memberlist.TransmitLimitedQueue
Expand Down Expand Up @@ -198,8 +198,8 @@ func start() error {
if err != nil {
return err
}
if len(*members) > 0 {
parts := strings.Split(*members, ",")
if len(*nodes) > 0 {
parts := strings.Split(*nodes, ",")
_, err := m.Join(parts)
if err != nil {
return err
Expand All @@ -212,7 +212,7 @@ func start() error {
RetransmitMult: 3,
}
node := m.LocalNode()
fmt.Printf("Local member %s:%d\n", node.Addr, node.Port)
fmt.Printf("Local node %s:%d\n", node.Addr, node.Port)
return nil
}

Expand Down

0 comments on commit 7c7ac6d

Please sign in to comment.