Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into DB-hard-delete
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerwins committed Sep 12, 2024
2 parents 16d8749 + 4e039bc commit 86a3f5d
Show file tree
Hide file tree
Showing 49 changed files with 2,357 additions and 591 deletions.
22 changes: 9 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
outputs:
build: ${{ steps.ci-target-check.outputs.build }}
bench: ${{ steps.ci-target-check.outputs.bench }}
sharding-test: ${{ steps.ci-target-check.outputs.sharding-test }}
complex-test: ${{ steps.ci-target-check.outputs.complex-test }}

steps:
- name: Checkout code
Expand All @@ -42,8 +42,10 @@ jobs:
- 'admin/**'
- 'api/converter/**'
sharding-test:
complex-test:
- 'server/backend/database/**'
- 'pkg/document/**'
- 'client/**'
build:
name: build
Expand Down Expand Up @@ -109,9 +111,6 @@ 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

Expand All @@ -136,12 +135,12 @@ 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.sharding-test == 'true' }}
if: ${{ needs.ci-target-check.outputs.complex-test == 'true' }}

steps:

Expand All @@ -153,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 @@ -177,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/...
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ 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
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.31
YORKIE_VERSION := 0.5.0

GO_PROJECT = github.com/yorkie-team/yorkie

Expand Down
27 changes: 27 additions & 0 deletions admin/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,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
}
27 changes: 27 additions & 0 deletions api/converter/from_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,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 @@ -539,6 +541,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
18 changes: 18 additions & 0 deletions api/converter/to_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ func ToOperations(ops []operations.Operation) ([]*api.Operation, error) {
pbOperation.Body, err = toTreeEdit(op)
case *operations.TreeStyle:
pbOperation.Body, err = toTreeStyle(op)
case *operations.ArraySet:
pbOperation.Body, err = toArraySet(op)
default:
return nil, ErrUnsupportedOperation
}
Expand Down Expand Up @@ -375,6 +377,22 @@ func toTreeStyle(style *operations.TreeStyle) (*api.Operation_TreeStyle_, error)
}, nil
}

func toArraySet(setByIndex *operations.ArraySet) (*api.Operation_ArraySet_, error) {
pbElem, err := toJSONElementSimple(setByIndex.Value())
if err != nil {
return nil, err
}

return &api.Operation_ArraySet_{
ArraySet: &api.Operation_ArraySet{
ParentCreatedAt: ToTimeTicket(setByIndex.ParentCreatedAt()),
CreatedAt: ToTimeTicket(setByIndex.CreatedAt()),
Value: pbElem,
ExecutedAt: ToTimeTicket(setByIndex.ExecutedAt()),
},
}, nil
}

func toJSONElementSimple(elem crdt.Element) (*api.JSONElementSimple, error) {
switch elem := elem.(type) {
case *crdt.Object:
Expand Down
2 changes: 1 addition & 1 deletion api/docs/yorkie.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.1.0
info:
title: Yorkie
description: "Yorkie is an open source document store for building collaborative editing applications."
version: v0.4.31
version: v0.5.0
servers:
- url: https://api.yorkie.dev
description: Production server
Expand Down
38 changes: 37 additions & 1 deletion api/docs/yorkie/v1/admin.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ info:
description: Yorkie is an open source document store for building collaborative
editing applications.
title: Yorkie
version: v0.4.31
version: v0.5.0
servers:
- description: Production server
url: https://api.yorkie.dev
Expand Down Expand Up @@ -1171,6 +1171,12 @@ components:
description: ""
title: add
type: object
arraySet:
$ref: '#/components/schemas/yorkie.v1.Operation.ArraySet'
additionalProperties: false
description: ""
title: array_set
type: object
edit:
$ref: '#/components/schemas/yorkie.v1.Operation.Edit'
additionalProperties: false
Expand Down Expand Up @@ -1257,6 +1263,36 @@ components:
type: object
title: Add
type: object
yorkie.v1.Operation.ArraySet:
additionalProperties: false
description: ""
properties:
createdAt:
$ref: '#/components/schemas/yorkie.v1.TimeTicket'
additionalProperties: false
description: ""
title: created_at
type: object
executedAt:
$ref: '#/components/schemas/yorkie.v1.TimeTicket'
additionalProperties: false
description: ""
title: executed_at
type: object
parentCreatedAt:
$ref: '#/components/schemas/yorkie.v1.TimeTicket'
additionalProperties: false
description: ""
title: parent_created_at
type: object
value:
$ref: '#/components/schemas/yorkie.v1.JSONElementSimple'
additionalProperties: false
description: ""
title: value
type: object
title: ArraySet
type: object
yorkie.v1.Operation.Edit:
additionalProperties: false
description: ""
Expand Down
38 changes: 37 additions & 1 deletion api/docs/yorkie/v1/resources.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ info:
description: Yorkie is an open source document store for building collaborative
editing applications.
title: Yorkie
version: v0.4.31
version: v0.5.0
servers:
- description: Production server
url: https://api.yorkie.dev
Expand Down Expand Up @@ -680,6 +680,12 @@ components:
description: ""
title: add
type: object
arraySet:
$ref: '#/components/schemas/yorkie.v1.Operation.ArraySet'
additionalProperties: false
description: ""
title: array_set
type: object
edit:
$ref: '#/components/schemas/yorkie.v1.Operation.Edit'
additionalProperties: false
Expand Down Expand Up @@ -766,6 +772,36 @@ components:
type: object
title: Add
type: object
yorkie.v1.Operation.ArraySet:
additionalProperties: false
description: ""
properties:
createdAt:
$ref: '#/components/schemas/yorkie.v1.TimeTicket'
additionalProperties: false
description: ""
title: created_at
type: object
executedAt:
$ref: '#/components/schemas/yorkie.v1.TimeTicket'
additionalProperties: false
description: ""
title: executed_at
type: object
parentCreatedAt:
$ref: '#/components/schemas/yorkie.v1.TimeTicket'
additionalProperties: false
description: ""
title: parent_created_at
type: object
value:
$ref: '#/components/schemas/yorkie.v1.JSONElementSimple'
additionalProperties: false
description: ""
title: value
type: object
title: ArraySet
type: object
yorkie.v1.Operation.Edit:
additionalProperties: false
description: ""
Expand Down
38 changes: 37 additions & 1 deletion api/docs/yorkie/v1/yorkie.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ info:
description: Yorkie is an open source document store for building collaborative
editing applications.
title: Yorkie
version: v0.4.31
version: v0.5.0
servers:
- description: Production server
url: https://api.yorkie.dev
Expand Down Expand Up @@ -664,6 +664,12 @@ components:
description: ""
title: add
type: object
arraySet:
$ref: '#/components/schemas/yorkie.v1.Operation.ArraySet'
additionalProperties: false
description: ""
title: array_set
type: object
edit:
$ref: '#/components/schemas/yorkie.v1.Operation.Edit'
additionalProperties: false
Expand Down Expand Up @@ -750,6 +756,36 @@ components:
type: object
title: Add
type: object
yorkie.v1.Operation.ArraySet:
additionalProperties: false
description: ""
properties:
createdAt:
$ref: '#/components/schemas/yorkie.v1.TimeTicket'
additionalProperties: false
description: ""
title: created_at
type: object
executedAt:
$ref: '#/components/schemas/yorkie.v1.TimeTicket'
additionalProperties: false
description: ""
title: executed_at
type: object
parentCreatedAt:
$ref: '#/components/schemas/yorkie.v1.TimeTicket'
additionalProperties: false
description: ""
title: parent_created_at
type: object
value:
$ref: '#/components/schemas/yorkie.v1.JSONElementSimple'
additionalProperties: false
description: ""
title: value
type: object
title: ArraySet
type: object
yorkie.v1.Operation.Edit:
additionalProperties: false
description: ""
Expand Down
5 changes: 5 additions & 0 deletions api/types/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ type DocEventBody struct {
Topic string
Payload []byte
}

// PayloadLen returns the size of the payload.
func (b *DocEventBody) PayloadLen() int {
return len(b.Payload)
}
Loading

0 comments on commit 86a3f5d

Please sign in to comment.