Skip to content

Commit fd02456

Browse files
committed
Merge main branch
1 parent 427619c commit fd02456

File tree

17 files changed

+1074
-139
lines changed

17 files changed

+1074
-139
lines changed

.github/workflows/docker-image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v5
1818
with:
1919
submodules: true
2020
# - name: Set up QEMU

.github/workflows/go-mod-fix.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: checkout
12-
uses: actions/checkout@v4
12+
uses: actions/checkout@v5
1313
with:
1414
fetch-depth: 2
1515
- name: fix

.github/workflows/go-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
os: [ [ubuntu-latest] ]
1616
runs-on: ${{ matrix.os }}
1717
steps:
18-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v5
1919
- uses: actions/setup-go@v5
2020
with:
2121
go-version-file: 'go.mod'

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Check out code into the Go module directory
17-
uses: actions/checkout@v4
17+
uses: actions/checkout@v5
1818
- name: golangci-lint
1919
uses: reviewdog/action-golangci-lint@v2
2020
with:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@
1919

2020
# Go workspace file
2121
go.work
22+
23+
# Built binary
24+
elastickv

adapter/distribution_server.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package adapter
2+
3+
import (
4+
"context"
5+
6+
"github.com/bootjp/elastickv/distribution"
7+
pb "github.com/bootjp/elastickv/proto"
8+
)
9+
10+
// DistributionServer serves distribution related gRPC APIs.
11+
type DistributionServer struct {
12+
engine *distribution.Engine
13+
pb.UnimplementedDistributionServer
14+
}
15+
16+
// NewDistributionServer creates a new server.
17+
func NewDistributionServer(e *distribution.Engine) *DistributionServer {
18+
return &DistributionServer{engine: e}
19+
}
20+
21+
// UpdateRoute allows updating route information.
22+
func (s *DistributionServer) UpdateRoute(start, end []byte, group uint64) {
23+
s.engine.UpdateRoute(start, end, group)
24+
}
25+
26+
// GetRoute returns route for a key.
27+
func (s *DistributionServer) GetRoute(ctx context.Context, req *pb.GetRouteRequest) (*pb.GetRouteResponse, error) {
28+
r, ok := s.engine.GetRoute(req.Key)
29+
if !ok {
30+
return &pb.GetRouteResponse{}, nil
31+
}
32+
return &pb.GetRouteResponse{
33+
Start: r.Start,
34+
End: r.End,
35+
RaftGroupId: r.GroupID,
36+
}, nil
37+
}
38+
39+
// GetTimestamp returns monotonically increasing timestamp.
40+
func (s *DistributionServer) GetTimestamp(ctx context.Context, req *pb.GetTimestampRequest) (*pb.GetTimestampResponse, error) {
41+
ts := s.engine.NextTimestamp()
42+
return &pb.GetTimestampResponse{Timestamp: ts}, nil
43+
}

adapter/dynamodb.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,19 @@ type DynamoDBServer struct {
3333
}
3434

3535
func NewDynamoDBServer(listen net.Listener, st store.ScanStore, coordinate *kv.Coordinate) *DynamoDBServer {
36-
return &DynamoDBServer{
36+
d := &DynamoDBServer{
3737
listen: listen,
3838
store: st,
3939
coordinator: coordinate,
4040
dynamoTranscoder: newDynamoDBTranscoder(),
4141
}
42-
}
43-
44-
func (d *DynamoDBServer) Run() error {
4542
mux := http.NewServeMux()
4643
mux.HandleFunc("/", d.handle)
4744
d.httpServer = &http.Server{Handler: mux, ReadHeaderTimeout: time.Second}
45+
return d
46+
}
47+
48+
func (d *DynamoDBServer) Run() error {
4849
if err := d.httpServer.Serve(d.listen); err != nil && !errors.Is(err, http.ErrServerClosed) {
4950
return errors.WithStack(err)
5051
}

0 commit comments

Comments
 (0)