Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/yorkie-team/yorkie into ref…
Browse files Browse the repository at this point in the history
…resh-auth-token
  • Loading branch information
chacha912 committed Oct 23, 2024
2 parents 411d1c9 + bd2ebe9 commit 5e54e52
Show file tree
Hide file tree
Showing 133 changed files with 7,902 additions and 2,861 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/...
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ output.txt
**/charts/*.tgz
/build/charts/yorkie-argocd/charts/
/build/charts/yorkie-monitoring/charts/
/build/charts/yorkie-mongodb/charts/
/build/charts/yorkie-cluster/charts/yorkie-mongodb/charts/
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@ and Yorkie adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)

## [Unreleased]

## [0.5.3] - 2024-09-23

## Changed

- Introduce VersionVector by @JOOHOJANG in https://github.com/yorkie-team/yorkie/pull/1047

## [0.5.2] - 2024-09-22

## Changed

- Detach documents when client is deactivated by @hackerwins in https://github.com/yorkie-team/yorkie/pull/1036
- Remove `jstype=string` from resources.proto by @Aswinr24 in https://github.com/yorkie-team/yorkie/pull/1040
- Include yorkie-mongodb to yorkie-cluster Helm Chart by @hyun98 in https://github.com/yorkie-team/yorkie/pull/1031

## [0.5.1] - 2024-09-15

### Added

- Add all-in-one Docker Compose and Grafana configuration by @window9u in https://github.com/yorkie-team/yorkie/pull/997
- Add metrics for WatchDocuments and enhance pushpull metrics by @emplam27 in https://github.com/yorkie-team/yorkie/pull/1008
- Add nginx-ingress-controller option by @emplam27 in https://github.com/yorkie-team/yorkie/pull/1022

### Changed

- Reduce CI test time by optimizing task execution by @binary-ho in https://github.com/yorkie-team/yorkie/pull/988
- Use random generated key by @window9u in https://github.com/yorkie-team/yorkie/pull/1010

## [0.5.0] - 2024-09-05

### 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.5.0
YORKIE_VERSION := 0.5.3

GO_PROJECT = github.com/yorkie-team/yorkie

Expand Down
10 changes: 9 additions & 1 deletion admin/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type Client struct {
client v1connect.AdminServiceClient
authInterceptor *AuthInterceptor
logger *zap.Logger
isInsecure bool
}

// New creates an instance of Client.
Expand Down Expand Up @@ -100,6 +101,7 @@ func New(opts ...Option) (*Client, error) {
conn: conn,
logger: logger,
authInterceptor: NewAuthInterceptor(options.Token),
isInsecure: options.IsInsecure,
}, nil
}

Expand All @@ -120,7 +122,7 @@ func Dial(rpcAddr string, opts ...Option) (*Client, error) {
// Dial dials to the admin service.
func (c *Client) Dial(rpcAddr string) error {
if !strings.Contains(rpcAddr, "://") {
if c.conn.Transport == nil {
if c.isInsecure {
rpcAddr = "http://" + rpcAddr
} else {
rpcAddr = "https://" + rpcAddr
Expand Down Expand Up @@ -327,10 +329,16 @@ func (c *Client) ListChangeSummaries(
return nil, err
}

vector, err := converter.FromVersionVector(snapshotMeta.Msg.VersionVector)
if err != nil {
return nil, err
}

newDoc, err := document.NewInternalDocumentFromSnapshot(
key,
seq,
snapshotMeta.Msg.Lamport,
vector,
snapshotMeta.Msg.Snapshot,
)

Expand Down
40 changes: 37 additions & 3 deletions api/converter/from_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,27 @@ func FromChangePack(pbPack *api.ChangePack) (*change.Pack, error) {
return nil, err
}

versionVector, err := FromVersionVector(pbPack.VersionVector)
if err != nil {
return nil, err
}

minSyncedTicket, err := fromTimeTicket(pbPack.MinSyncedTicket)
if err != nil {
return nil, err
}

return &change.Pack{
pack := &change.Pack{
DocumentKey: key.Key(pbPack.DocumentKey),
Checkpoint: fromCheckpoint(pbPack.Checkpoint),
Changes: changes,
Snapshot: pbPack.Snapshot,
MinSyncedTicket: minSyncedTicket,
IsRemoved: pbPack.IsRemoved,
}, nil
VersionVector: versionVector,
MinSyncedTicket: minSyncedTicket,
}

return pack, nil
}

func fromCheckpoint(pbCheckpoint *api.Checkpoint) change.Checkpoint {
Expand Down Expand Up @@ -147,14 +155,40 @@ func fromChangeID(id *api.ChangeID) (change.ID, error) {
if err != nil {
return change.InitialID, err
}

vector, err := FromVersionVector(id.VersionVector)
if err != nil {
return change.InitialID, err
}

return change.NewID(
id.ClientSeq,
id.ServerSeq,
id.Lamport,
actorID,
vector,
), nil
}

// FromVersionVector converts the given Protobuf formats to model format.
func FromVersionVector(pbVersionVector *api.VersionVector) (time.VersionVector, error) {
versionVector := make(time.VersionVector)
// TODO(hackerwins): Old clients do not send VersionVector. We should remove this later.
if pbVersionVector == nil {
return versionVector, nil
}

for id, lamport := range pbVersionVector.Vector {
actorID, err := time.ActorIDFromHex(id)
if err != nil {
return nil, err
}
versionVector.Set(actorID, lamport)
}

return versionVector, nil
}

// FromDocumentID converts the given Protobuf formats to model format.
func FromDocumentID(pbID string) (types.ID, error) {
id := types.ID(pbID)
Expand Down
45 changes: 39 additions & 6 deletions api/converter/to_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,18 @@ func ToChangePack(pack *change.Pack) (*api.ChangePack, error) {
return nil, err
}

pbVersionVector, err := ToVersionVector(pack.VersionVector)
if err != nil {
return nil, err
}

return &api.ChangePack{
DocumentKey: pack.DocumentKey.String(),
Checkpoint: ToCheckpoint(pack.Checkpoint),
Changes: pbChanges,
Snapshot: pack.Snapshot,
MinSyncedTicket: ToTimeTicket(pack.MinSyncedTicket),
VersionVector: pbVersionVector,
IsRemoved: pack.IsRemoved,
}, nil
}
Expand All @@ -155,13 +161,35 @@ func ToCheckpoint(cp change.Checkpoint) *api.Checkpoint {
}

// ToChangeID converts the given model format to Protobuf format.
func ToChangeID(id change.ID) *api.ChangeID {
func ToChangeID(id change.ID) (*api.ChangeID, error) {
pbVersionVector, err := ToVersionVector(id.VersionVector())
if err != nil {
return nil, err
}
return &api.ChangeID{
ClientSeq: id.ClientSeq(),
ServerSeq: id.ServerSeq(),
Lamport: id.Lamport(),
ActorId: id.ActorID().Bytes(),
ClientSeq: id.ClientSeq(),
ServerSeq: id.ServerSeq(),
Lamport: id.Lamport(),
ActorId: id.ActorID().Bytes(),
VersionVector: pbVersionVector,
}, nil
}

// ToVersionVector converts the given model format to Protobuf format.
func ToVersionVector(vector time.VersionVector) (*api.VersionVector, error) {
pbVersionVector := make(map[string]int64)
for actor, clock := range vector {
id, err := time.ActorIDFromBytes(actor[:])
if err != nil {
return nil, err
}

pbVersionVector[id.String()] = clock
}

return &api.VersionVector{
Vector: pbVersionVector,
}, nil
}

// ToDocEventType converts the given model format to Protobuf format.
Expand Down Expand Up @@ -243,8 +271,13 @@ func ToChanges(changes []*change.Change) ([]*api.Change, error) {
return nil, err
}

pbChangeID, err := ToChangeID(c.ID())
if err != nil {
return nil, err
}

pbChanges = append(pbChanges, &api.Change{
Id: ToChangeID(c.ID()),
Id: pbChangeID,
Message: c.Message(),
Operations: pbOperations,
PresenceChange: ToPresenceChange(c.PresenceChange()),
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.5.0
version: v0.5.3
servers:
- url: https://api.yorkie.dev
description: Production server
Expand Down
Loading

0 comments on commit 5e54e52

Please sign in to comment.