Skip to content

Commit

Permalink
fix(node): used sql instead raft as store (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlangzi authored Mar 19, 2024
1 parent dccf187 commit 75bf8a9
Show file tree
Hide file tree
Showing 21 changed files with 524 additions and 1,049 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# dlm
Distributed Lock Manager
a fault-tolerant distributed lock manager for Go

![License](https://img.shields.io/badge/license-MIT-green.svg)
[![Tests](https://github.com/yaitoo/dlm/actions/workflows/tests.yml/badge.svg)](https://github.com/yaitoo/dlm/actions/workflows/tests.yml)
[![Go Reference](https://pkg.go.dev/badge/github.com/yaitoo/dlm.svg)](https://pkg.go.dev/github.com/yaitoo/dlm)
[![Codecov](https://codecov.io/gh/yaitoo/dlm/branch/main/graph/badge.svg)](https://codecov.io/gh/yaitoo/dlm)
[![GitHub Release](https://img.shields.io/github/v/release/yaitoo/dlm)](https://github.com/yaitoo/dlm/blob/main/CHANGELOG.md)
[![Go Report Card](https://goreportcard.com/badge/yaitoo/dlm)](http://goreportcard.com/report/yaitoo/dlm)


inspired by
Expand Down
100 changes: 0 additions & 100 deletions cluster.go

This file was deleted.

17 changes: 0 additions & 17 deletions cluster_option.go

This file was deleted.

174 changes: 0 additions & 174 deletions cluster_test.go

This file was deleted.

12 changes: 0 additions & 12 deletions cmd.go

This file was deleted.

40 changes: 24 additions & 16 deletions dlm.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,34 @@ import (
)

var (
ErrExpiredLease = errors.New("dlm: lease expires")
ErrNoLease = errors.New("dlm: no lease")
ErrNotYourLease = errors.New("dlm: not your lease")
ErrStaleNonce = errors.New("dlm: stale nonce")
ErrInvalidTopic = errors.New("dlm: topic can't starts with @")
ErrNotRaftLeader = errors.New("dlm: not raft leader")
ErrAlreadyLocked = errors.New("dlm: already locked by others")
ErrNoConsensus = errors.New("dlm: no consensus")
ErrClusterNotStarted = errors.New("dlm: cluster is not started")
ErrFrozenTopic = errors.New("dlm: topic is frozen")
ErrExpiredLease = errors.New("dlm: lease expires")
ErrNoLease = errors.New("dlm: no lease")
ErrNotYourLease = errors.New("dlm: not your lease")
ErrLeaseExists = errors.New("dlm: lease exists")

ErrFrozenTopic = errors.New("dlm: topic is frozen")

ErrBadDatabase = errors.New("dlm: bad database operation")
)

var (
DefaultRaftTimeout = 3 * time.Second
DefaultTimeout = 3 * time.Second
DefaultLeaseTerm = 5 * time.Second
DefaultRetainSnapshotCount = 2
Logger = slog.Default()
DefaultTimeout = 3 * time.Second
DefaultLeaseTerm = 5 * time.Second

Logger = slog.Default()
)

const (
TopicTerms = "@terms:"
CreateTableLease = "CREATE TABLE IF NOT EXISTS dlm_lease(" +
"`topic` varchar(20) NOT NULL," +
"`key` varchar(50) NOT NULL," +
"`lessee` varchar(36) NOT NULL," +
"`since` int NOT NULL DEFAULT '0'," +
"`ttl` int NOT NULL DEFAULT '0'," +
"PRIMARY KEY (topic, key));"

CreateTableTopic = "CREATE TABLE IF NOT EXISTS dlm_topic(" +
"`topic` varchar(20) NOT NULL," +
"`ttl` int NOT NULL DEFAULT '0'," +
"PRIMARY KEY (topic));"
)
Loading

0 comments on commit 75bf8a9

Please sign in to comment.