Skip to content

Commit

Permalink
Add gateway flag to server command
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerwins committed Oct 16, 2024
1 parent 31cc753 commit e1782a3
Show file tree
Hide file tree
Showing 21 changed files with 156 additions and 165 deletions.
24 changes: 12 additions & 12 deletions api/docs/yorkie/v1/system.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ paths:
post:
description: ""
requestBody:
$ref: '#/components/requestBodies/yorkie.v1.SystemService.DetachDocument.yorkie.v1.DetachDocumentRequestBySystem'
$ref: '#/components/requestBodies/yorkie.v1.SystemService.DetachDocument.yorkie.v1.SystemServiceDetachDocumentRequest'
responses:
"200":
$ref: '#/components/responses/yorkie.v1.SystemService.DetachDocument.yorkie.v1.DetachDocumentResponseBySystem'
$ref: '#/components/responses/yorkie.v1.SystemService.DetachDocument.yorkie.v1.SystemServiceDetachDocumentResponse'
default:
$ref: '#/components/responses/connect.error'
tags:
- yorkie.v1.SystemService
components:
requestBodies:
yorkie.v1.SystemService.DetachDocument.yorkie.v1.DetachDocumentRequestBySystem:
yorkie.v1.SystemService.DetachDocument.yorkie.v1.SystemServiceDetachDocumentRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/yorkie.v1.DetachDocumentRequestBySystem'
$ref: '#/components/schemas/yorkie.v1.SystemServiceDetachDocumentRequest'
application/proto:
schema:
$ref: '#/components/schemas/yorkie.v1.DetachDocumentRequestBySystem'
$ref: '#/components/schemas/yorkie.v1.SystemServiceDetachDocumentRequest'
required: true
responses:
connect.error:
Expand All @@ -43,14 +43,14 @@ components:
schema:
$ref: '#/components/schemas/connect.error'
description: ""
yorkie.v1.SystemService.DetachDocument.yorkie.v1.DetachDocumentResponseBySystem:
yorkie.v1.SystemService.DetachDocument.yorkie.v1.SystemServiceDetachDocumentResponse:
content:
application/json:
schema:
$ref: '#/components/schemas/yorkie.v1.DetachDocumentResponseBySystem'
$ref: '#/components/schemas/yorkie.v1.SystemServiceDetachDocumentResponse'
application/proto:
schema:
$ref: '#/components/schemas/yorkie.v1.DetachDocumentResponseBySystem'
$ref: '#/components/schemas/yorkie.v1.SystemServiceDetachDocumentResponse'
description: ""
schemas:
connect.error:
Expand Down Expand Up @@ -81,7 +81,7 @@ components:
type: string
title: Connect Error
type: object
yorkie.v1.DetachDocumentRequestBySystem:
yorkie.v1.SystemServiceDetachDocumentRequest:
additionalProperties: false
description: ""
properties:
Expand All @@ -106,12 +106,12 @@ components:
types.Client, types.DocumentSummary'
title: project_id
type: string
title: DetachDocumentRequestBySystem
title: SystemServiceDetachDocumentRequest
type: object
yorkie.v1.DetachDocumentResponseBySystem:
yorkie.v1.SystemServiceDetachDocumentResponse:
additionalProperties: false
description: ""
title: DetachDocumentResponseBySystem
title: SystemServiceDetachDocumentResponse
type: object
securitySchemes:
ApiKeyAuth:
Expand Down
104 changes: 53 additions & 51 deletions api/yorkie/v1/system.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions api/yorkie/v1/system.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ option java_package = "dev.yorkie.api.v1";

// System is a service that provides an API for Cluster.
service SystemService {
rpc DetachDocument (DetachDocumentRequestBySystem) returns (DetachDocumentResponseBySystem) {}
rpc DetachDocument (SystemServiceDetachDocumentRequest) returns (SystemServiceDetachDocumentResponse) {}
}

message DetachDocumentRequestBySystem {
message SystemServiceDetachDocumentRequest {
// TODO(hackerwins): Consider to replace this fields with types.Project, types.Client, types.DocumentSummary
string project_id = 1;
string client_id = 2;
string document_id = 3;
string document_key = 4;
}

message DetachDocumentResponseBySystem {}
message SystemServiceDetachDocumentResponse {}
12 changes: 6 additions & 6 deletions api/yorkie/v1/v1connect/system.connect.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions cmd/yorkie/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ func init() {
server.DefaultHostname,
"Yorkie Server Hostname",
)
cmd.Flags().StringVar(
&conf.Backend.GatewayAddr,
"backend-gateway-addr",
server.DefaultGatewayAddr,
"Gateway address",
)

rootCmd.AddCommand(cmd)
}
12 changes: 12 additions & 0 deletions pkg/document/internal_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ func (d *InternalDocument) Checkpoint() change.Checkpoint {
return d.checkpoint
}

// SyncCheckpoint syncs the checkpoint and the changeID with the given serverSeq
// and clientSeq.
func (d *InternalDocument) SyncCheckpoint(serverSeq int64, clientSeq uint32) {
d.changeID = change.NewID(
clientSeq,
serverSeq,
d.changeID.Lamport(),
d.changeID.ActorID(),
)
d.checkpoint = d.checkpoint.SyncClientSeq(clientSeq)
}

// HasLocalChanges returns whether this document has local changes or not.
func (d *InternalDocument) HasLocalChanges() bool {
return len(d.localChanges) > 0
Expand Down
3 changes: 3 additions & 0 deletions server/backend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ type Config struct {

// Hostname is yorkie server hostname. hostname is used by metrics.
Hostname string `yaml:"Hostname"`

// GatewayAddr is the address of the gateway server.
GatewayAddr string `yaml:"GatewayAddr"`
}

// Validate validates this config.
Expand Down
Loading

0 comments on commit e1782a3

Please sign in to comment.