Skip to content

Commit

Permalink
Merge branch 'main' into hybrid-clock
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerwins committed Sep 26, 2024
2 parents eec25b3 + 0871fac commit 46081f7
Show file tree
Hide file tree
Showing 82 changed files with 5,294 additions and 1,249 deletions.
66 changes: 51 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
paths-ignore:
- 'api/docs/**'
- 'build/charts/**'
- 'design/**'
- '**/*.md'
- '**/*.txt'
- '**/.gitignore'
Expand All @@ -16,11 +17,44 @@ env:
GO_VERSION: '1.21'

jobs:
ci-target-check:
runs-on: ubuntu-latest

outputs:
build: ${{ steps.ci-target-check.outputs.build }}
bench: ${{ steps.ci-target-check.outputs.bench }}
complex-test: ${{ steps.ci-target-check.outputs.complex-test }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: CI target check by path
uses: dorny/paths-filter@v3
id: ci-target-check
with:
filters: |
build: '**'
bench:
- 'pkg/**'
- 'server/**'
- 'client/**'
- 'admin/**'
- 'api/converter/**'
complex-test:
- 'server/backend/database/**'
- 'pkg/document/**'
- 'client/**'
build:
name: build
runs-on: ubuntu-latest
steps:

needs: ci-target-check
if: ${{ needs.ci-target-check.outputs.build == 'true' }}

steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
Expand All @@ -47,7 +81,7 @@ jobs:
run: make build

- name: Stack
run: docker-compose -f build/docker/docker-compose.yml up --build -d
run: docker compose -f build/docker/docker-compose.yml up --build -d

- name: Test
run: go test -tags integration -race -coverprofile=coverage.txt -covermode=atomic -v ./...
Expand All @@ -58,11 +92,15 @@ jobs:
file: ./coverage.txt
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

bench:
name: bench
runs-on: ubuntu-latest
permissions: write-all

needs: ci-target-check
if: ${{ needs.ci-target-check.outputs.bench == 'true' }}

steps:

- name: Set up Go ${{ env.GO_VERSION }}
Expand All @@ -73,11 +111,8 @@ jobs:
- name: Check out code
uses: actions/checkout@v4

- name: Get tools dependencies
run: make tools

- name: Stack
run: docker-compose -f build/docker/docker-compose.yml up --build -d
run: docker compose -f build/docker/docker-compose.yml up --build -d

- name: Bench
run: make bench
Expand All @@ -100,9 +135,13 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-always: true

sharding_test:
name: sharding_test
complex-test:
name: complex-test
runs-on: ubuntu-latest

needs: ci-target-check
if: ${{ needs.ci-target-check.outputs.complex-test == 'true' }}

steps:

- name: Set up Go ${{ env.GO_VERSION }}
Expand All @@ -113,9 +152,6 @@ jobs:
- name: Check out code
uses: actions/checkout@v4

- name: Get tools dependencies
run: make tools

- name: Check Docker Compose Version
run: docker compose --version

Expand All @@ -127,7 +163,7 @@ jobs:

- name: Initialize the Shard 1
run: docker compose -f build/docker/sharding/docker-compose.yml exec shard1-1 mongosh test /scripts/init-shard1-1.js

- name: Initialize the Shard 2
run: docker compose -f build/docker/sharding/docker-compose.yml exec shard2-1 mongosh test /scripts/init-shard2-1.js

Expand All @@ -137,5 +173,5 @@ jobs:
- name: Initialize the Mongos
run: docker compose -f build/docker/sharding/docker-compose.yml exec mongos1 mongosh test /scripts/init-mongos1.js

- name: Run the tests with sharding tag
run: go test -tags sharding -race -v ./test/sharding/...
- name: Run the tests with complex tag
run: go test -tags complex -race -v ./test/complex/...
66 changes: 66 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,72 @@ and Yorkie adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)

## [Unreleased]

## [0.5.0] - 2024-09-05

### Added

- Add Concurrency Tests between Array Operations by @cloneot in https://github.com/yorkie-team/yorkie/pull/985
- Add metric for WatchDocument streams by @emplam27 in https://github.com/yorkie-team/yorkie/pull/998
- Add Account Deletion and Change Password to CLI by @sigmaith in https://github.com/yorkie-team/yorkie/pull/983

### Changed

- Optimize FindChangeInfosBetweenServerSeqs to prevent unnecessary Query by @kokodak in https://github.com/yorkie-team/yorkie/pull/974
- Rename SetByIndex to ArraySet by @hackerwins in https://github.com/yorkie-team/yorkie/pull/995

### Fixed

- Set `updated_at` with `created_at` when creating Document by @window9u in https://github.com/yorkie-team/yorkie/pull/977

## [0.4.31] - 2024-08-21

### Added

- Add a metric to collect the number of background routines by @kokodak in https://github.com/yorkie-team/yorkie/pull/963

### Changed

- Modify health check endpoint and add HEAD method by @taeng0204 in https://github.com/yorkie-team/yorkie/pull/958
- [Revised] Fine-tuned CI Workflows in PR by @krapie in https://github.com/yorkie-team/yorkie/pull/965

### Fixed

- Fix invalid test case in FindDocInfosByKeys by @kokodak in https://github.com/yorkie-team/yorkie/pull/972

## [0.4.30] - 2024-08-09

### Added

- Add HTTP health check handler for server health monitoring by @taeng0204 in https://github.com/yorkie-team/yorkie/pull/952
- Show Server Version in Yorkie CLI by @hyun98 in https://github.com/yorkie-team/yorkie/pull/938

## [0.4.29] - 2024-08-05

### Added

- Support basic account action for admin by @gusah009 in https://github.com/yorkie-team/yorkie/pull/934

### Changed

- Update docker compose command to V2 by @fourjae in https://github.com/yorkie-team/yorkie/pull/950

### Fixed

- Fix FindDocInfosByKeys when keys is empty by @blurfx in https://github.com/yorkie-team/yorkie/pull/945
- Handle panic during conversion to connectCode by @blurfx in https://github.com/yorkie-team/yorkie/pull/951

## [0.4.28] - 2024-07-25

### Added

- Enhance housekeeping to add variety of tasks by @hackerwins in https://github.com/yorkie-team/yorkie/pull/932
- Enhance GetDocuments API by adding bulk retrieval by @kokodak in https://github.com/yorkie-team/yorkie/pull/931
- Improve performance for creating crdt.TreeNode by @m4ushold in https://github.com/yorkie-team/yorkie/pull/939

### Changed

- Update `updated_at` only when there are operations in changes by @window9u in https://github.com/yorkie-team/yorkie/pull/935

## [0.4.27] - 2024-07-11

### Changed
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ make build # executable: ./bin/yorkie
You can set testing environment via Docker Compose. It is needed because integration tests require local applications like MongoDB.

```sh
docker-compose -f build/docker/docker-compose.yml up --build -d
docker compose -f build/docker/docker-compose.yml up --build -d
make test
```

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
YORKIE_VERSION := 0.4.27
YORKIE_VERSION := 0.5.0

GO_PROJECT = github.com/yorkie-team/yorkie

Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
[![CodeCov](https://img.shields.io/codecov/c/github/yorkie-team/yorkie)](https://codecov.io/gh/yorkie-team/yorkie)
[![Godoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://godoc.org/github.com/yorkie-team/yorkie)

Yorkie is an open source document store for building collaborative editing applications. Yorkie uses JSON-like documents(CRDT) with optional types.
Yorkie is an open-source document store for building real-time collaborative applications. It uses JSON-like documents(CRDT) with optional types.

Yorkie consists of three main components: Client, Document and Server.

```
Client "A" (Go) Self-Hosted Server Or Cloud MongoDB or MemDB
Client "A" (Go) Server(Cloud or Self-Hosted) MongoDB or MemDB
┌───────────────────┐ ┌────────────────────────┐ ┌───────────┐
│ Document "D-1" │◄─Changes─►│ Project "P-1" │ │ Changes │
│ { a: 1, b: {} } │ │ ┌───────────────────┐ │◄─►│ Snapshots │
Expand All @@ -33,10 +33,13 @@ Yorkie consists of three main components: Client, Document and Server.
└────────────────────┘
```

- Clients can have a replica of the document representing an application model locally on several devices.
- Each client can independently update the document on their local device, even while offline.
- When a network connection is available, the client figures out which changes need to be synced from one device to another, and brings them into the same state.
- If the document was changed concurrently on different devices, Yorkie automatically syncs the changes, so that every replica ends up in the same state with resolving conflict.
Key Features:

- Clients: Clients can have a local replica of the document representing an application model on several devices.
- Offline Editing: Each client can independently update the document on their local device, even while offline.
- Synchronization: When a network connection is available, the client figures out which changes need to be synced from one device to another, and brings them into the same state.
- Conflict Resolution: If the document was changed concurrently on different devices, Yorkie automatically syncs the changes, so that every replica ends up in the same state with resolving conflicts.
- Database Integration: Yorkie supports MongoDB and MemDB as the underlying data storage.

## Documentation

Expand Down
41 changes: 41 additions & 0 deletions admin/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,20 @@ func (c *Client) ListChangeSummaries(
return summaries, nil
}

// GetServerVersion gets the server version.
func (c *Client) GetServerVersion(ctx context.Context) (*types.VersionDetail, error) {
response, err := c.client.GetServerVersion(ctx, connect.NewRequest(&api.GetServerVersionRequest{}))
if err != nil {
return nil, err
}

return &types.VersionDetail{
YorkieVersion: response.Msg.YorkieVersion,
GoVersion: response.Msg.GoVersion,
BuildDate: response.Msg.BuildDate,
}, nil
}

/**
* withShardKey returns a context with the given shard key in metadata.
*/
Expand All @@ -369,3 +383,30 @@ func withShardKey[T any](conn *connect.Request[T], keys ...string) *connect.Requ

return conn
}

// DeleteAccount deletes the user's account.
func (c *Client) DeleteAccount(ctx context.Context, username, password string) error {
_, err := c.client.DeleteAccount(ctx, connect.NewRequest(&api.DeleteAccountRequest{
Username: username,
Password: password,
}))
if err != nil {
return err
}

return nil
}

// ChangePassword changes the user's password.
func (c *Client) ChangePassword(ctx context.Context, username, password, newPassword string) error {
_, err := c.client.ChangePassword(ctx, connect.NewRequest(&api.ChangePasswordRequest{
Username: username,
CurrentPassword: password,
NewPassword: newPassword,
}))
if err != nil {
return err
}

return nil
}
38 changes: 31 additions & 7 deletions api/converter/from_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ func FromOperations(pbOps []*api.Operation) ([]operations.Operation, error) {
op, err = fromTreeEdit(decoded.TreeEdit)
case *api.Operation_TreeStyle_:
op, err = fromTreeStyle(decoded.TreeStyle)
case *api.Operation_ArraySet_:
op, err = fromArraySet(decoded.ArraySet)
default:
return nil, ErrUnsupportedOperation
}
Expand Down Expand Up @@ -588,6 +590,31 @@ func fromTreeStyle(pbTreeStyle *api.Operation_TreeStyle) (*operations.TreeStyle,
), nil
}

func fromArraySet(pbSetByIndex *api.Operation_ArraySet) (*operations.ArraySet, error) {
parentCreatedAt, err := fromTimeTicket(pbSetByIndex.ParentCreatedAt)
if err != nil {
return nil, err
}
createdAt, err := fromTimeTicket(pbSetByIndex.CreatedAt)
if err != nil {
return nil, err
}
elem, err := fromElement(pbSetByIndex.Value)
if err != nil {
return nil, err
}
executedAt, err := fromTimeTicket(pbSetByIndex.ExecutedAt)
if err != nil {
return nil, err
}
return operations.NewArraySet(
parentCreatedAt,
createdAt,
elem,
executedAt,
), nil
}

func fromCreatedAtMapByActor(
pbCreatedAtMapByActor map[string]*api.TimeTicket,
) (map[string]*time.Ticket, error) {
Expand Down Expand Up @@ -632,18 +659,15 @@ func FromTreeNodes(pbNodes []*api.TreeNode) (*crdt.TreeNode, error) {
}

root := nodes[len(nodes)-1]
depthTable := make(map[int32]*crdt.TreeNode)
depthTable[pbNodes[len(nodes)-1].Depth] = nodes[len(nodes)-1]
for i := len(nodes) - 2; i >= 0; i-- {
var parent *crdt.TreeNode
for j := i + 1; j < len(nodes); j++ {
if pbNodes[i].Depth-1 == pbNodes[j].Depth {
parent = nodes[j]
break
}
}
var parent *crdt.TreeNode = depthTable[pbNodes[i].Depth-1]

if err := parent.Prepend(nodes[i]); err != nil {
return nil, err
}
depthTable[pbNodes[i].Depth] = nodes[i]
}

root.Index.UpdateDescendantsSize()
Expand Down
Loading

0 comments on commit 46081f7

Please sign in to comment.