Skip to content

Commit

Permalink
Rename Agent to Server (#316)
Browse files Browse the repository at this point in the history
Initially, we had a plan to install Yorkie on the nodes where MongoDB
is installed, so we named it Agent.

However, we implemented Agents like normal Servers and the name
of Agent is confusing. So this commit renames it as Server.
  • Loading branch information
hackerwins committed May 2, 2022
1 parent 653a12d commit d57f04c
Show file tree
Hide file tree
Showing 89 changed files with 380 additions and 380 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ documents(CRDT) with optional types.
Yorkie consists of three main components: Client, Document and Agent.

```
Client "A" (Go) Agent MemDB or MongoDB
Client "A" (Go) Server MemDB or MongoDB
┌───────────────────┐ ┌────────────────────────┐ ┌───────────┐
│ Document "D-1" │◄─Changes─►│ Collection "C-1" │ │ Changes │
│ { a: 1, b: {} } │ │ ┌───────────────────┐ │◄─►│ Snapshots │
Expand Down
2 changes: 1 addition & 1 deletion api/converter/from_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/yorkie-team/yorkie/pkg/document/key"
"github.com/yorkie-team/yorkie/pkg/document/operations"
"github.com/yorkie-team/yorkie/pkg/document/time"
"github.com/yorkie-team/yorkie/yorkie/backend/sync"
"github.com/yorkie-team/yorkie/server/backend/sync"
)

// FromProjects converts the given Protobuf formats to model format.
Expand Down
2 changes: 1 addition & 1 deletion api/converter/to_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/yorkie-team/yorkie/pkg/document/key"
"github.com/yorkie-team/yorkie/pkg/document/operations"
"github.com/yorkie-team/yorkie/pkg/document/time"
"github.com/yorkie-team/yorkie/yorkie/backend/sync"
"github.com/yorkie-team/yorkie/server/backend/sync"
)

// ToProjects converts the given model to Protobuf.
Expand Down
2 changes: 1 addition & 1 deletion api/types/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/yorkie-team/yorkie/pkg/document/time"
)

// Client represents the Client that communicates with the Agent.
// Client represents the Client that communicates with the Server.
type Client struct {
ID *time.ActorID
MetadataInfo MetadataInfo
Expand Down
2 changes: 1 addition & 1 deletion api/types/event.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package types

// DocEventType represents the event that the Agent delivers to the client.
// DocEventType represents the event that the Server delivers to the client.
type DocEventType string

const (
Expand Down
16 changes: 8 additions & 8 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ type Attachment struct {
peers map[string]types.MetadataInfo
}

// Client is a normal client that can communicate with the agent.
// Client is a normal client that can communicate with the server.
// It has documents and sends changes of the document in local
// to the agent to synchronize with other replicas in remote.
// to the server to synchronize with other replicas in remote.
type Client struct {
conn *grpc.ClientConn
client api.YorkieClient
Expand Down Expand Up @@ -184,8 +184,8 @@ func (c *Client) Close() error {
return c.conn.Close()
}

// Activate activates this client. That is, it registers itself to the agent
// and receives a unique ID from the agent. The given ID is used to distinguish
// Activate activates this client. That is, it registers itself to the server
// and receives a unique ID from the server. The given ID is used to distinguish
// different clients.
func (c *Client) Activate(ctx context.Context) error {
if c.status == activated {
Expand Down Expand Up @@ -228,7 +228,7 @@ func (c *Client) Deactivate(ctx context.Context) error {
return nil
}

// Attach attaches the given document to this client. It tells the agent that
// Attach attaches the given document to this client. It tells the server that
// this client will synchronize the given document.
func (c *Client) Attach(ctx context.Context, doc *document.Document) error {
if c.status != activated {
Expand Down Expand Up @@ -277,7 +277,7 @@ func (c *Client) Attach(ctx context.Context, doc *document.Document) error {
}

// Detach detaches the given document from this client. It tells the
// agent that this client will no longer synchronize the given document.
// server that this client will no longer synchronize the given document.
//
// To collect garbage things like CRDT tombstones left on the document, all the
// changes should be applied to other replicas before GC time. For this, if the
Expand Down Expand Up @@ -319,8 +319,8 @@ func (c *Client) Detach(ctx context.Context, doc *document.Document) error {
return nil
}

// Sync pushes local changes of the attached documents to the Agent and
// receives changes of the remote replica from the agent then apply them to
// Sync pushes local changes of the attached documents to the server and
// receives changes of the remote replica from the server then apply them to
// local documents.
func (c *Client) Sync(ctx context.Context, keys ...key.Key) error {
if len(keys) == 0 {
Expand Down
58 changes: 29 additions & 29 deletions cmd/yorkie/agent.go → cmd/yorkie/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (

"github.com/spf13/cobra"

"github.com/yorkie-team/yorkie/yorkie"
"github.com/yorkie-team/yorkie/yorkie/backend/db/mongo"
"github.com/yorkie-team/yorkie/yorkie/backend/sync/etcd"
"github.com/yorkie-team/yorkie/yorkie/logging"
"github.com/yorkie-team/yorkie/server"
"github.com/yorkie-team/yorkie/server/backend/db/mongo"
"github.com/yorkie-team/yorkie/server/backend/sync/etcd"
"github.com/yorkie-team/yorkie/server/logging"
)

var (
Expand Down Expand Up @@ -57,13 +57,13 @@ var (
etcdPassword string
etcdLockLeaseTime time.Duration

conf = yorkie.NewConfig()
conf = server.NewConfig()
)

func newAgentCmd() *cobra.Command {
func newServerCmd() *cobra.Command {
return &cobra.Command{
Use: "agent [options]",
Short: "Start yorkie agent",
Use: "server [options]",
Short: "Start Yorkie server",
RunE: func(cmd *cobra.Command, args []string) error {
conf.Backend.AuthWebhookMaxWaitInterval = authWebhookMaxWaitInterval.String()
conf.Backend.AuthWebhookCacheAuthTTL = authWebhookCacheAuthTTL.String()
Expand Down Expand Up @@ -93,7 +93,7 @@ func newAgentCmd() *cobra.Command {

// If config file is given, command-line arguments will be overwritten.
if flagConfPath != "" {
parsed, err := yorkie.NewConfigFromFile(flagConfPath)
parsed, err := server.NewConfigFromFile(flagConfPath)
if err != nil {
return err
}
Expand All @@ -104,7 +104,7 @@ func newAgentCmd() *cobra.Command {
return err
}

y, err := yorkie.New(conf)
y, err := server.New(conf)
if err != nil {
return err
}
Expand All @@ -122,7 +122,7 @@ func newAgentCmd() *cobra.Command {
}
}

func handleSignal(r *yorkie.Yorkie) int {
func handleSignal(r *server.Yorkie) int {
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)

Expand Down Expand Up @@ -159,7 +159,7 @@ func handleSignal(r *yorkie.Yorkie) int {
}

func init() {
cmd := newAgentCmd()
cmd := newServerCmd()
cmd.Flags().StringVarP(
&flagConfPath,
"config",
Expand All @@ -177,7 +177,7 @@ func init() {
cmd.Flags().IntVar(
&conf.RPC.Port,
"rpc-port",
yorkie.DefaultRPCPort,
server.DefaultRPCPort,
"RPC port",
)
cmd.Flags().StringVar(
Expand All @@ -195,13 +195,13 @@ func init() {
cmd.Flags().Uint64Var(
&conf.RPC.MaxRequestBytes,
"rpc-max-requests-bytes",
yorkie.DefaultRPCMaxRequestsBytes,
server.DefaultRPCMaxRequestsBytes,
"Maximum client request size in bytes the server will accept.",
)
cmd.Flags().IntVar(
&conf.Profiling.Port,
"profiling-port",
yorkie.DefaultProfilingPort,
server.DefaultProfilingPort,
"Profiling port",
)
cmd.Flags().BoolVar(
Expand All @@ -213,19 +213,19 @@ func init() {
cmd.Flags().DurationVar(
&housekeepingInterval,
"housekeeping-interval",
yorkie.DefaultHousekeepingInterval,
server.DefaultHousekeepingInterval,
"housekeeping interval between housekeeping runs",
)
cmd.Flags().DurationVar(
&housekeepingDeactivateThreshold,
"housekeeping-deactivate-threshold",
yorkie.DefaultHousekeepingDeactivateThreshold,
server.DefaultHousekeepingDeactivateThreshold,
"time after which clients are considered deactivate",
)
cmd.Flags().IntVar(
&conf.Housekeeping.CandidatesLimit,
"housekeeping-candidates-limit",
yorkie.DefaultHousekeepingCandidateLimit,
server.DefaultHousekeepingCandidateLimit,
"candidates limit for a single housekeeping run",
)
cmd.Flags().StringVar(
Expand All @@ -237,19 +237,19 @@ func init() {
cmd.Flags().DurationVar(
&mongoConnectionTimeout,
"mongo-connection-timeout",
yorkie.DefaultMongoConnectionTimeout,
server.DefaultMongoConnectionTimeout,
"Mongo DB's connection timeout",
)
cmd.Flags().StringVar(
&mongoYorkieDatabase,
"mongo-yorkie-database",
yorkie.DefaultMongoYorkieDatabase,
server.DefaultMongoYorkieDatabase,
"Yorkie's database name in MongoDB",
)
cmd.Flags().DurationVar(
&mongoPingTimeout,
"mongo-ping-timeout",
yorkie.DefaultMongoPingTimeout,
server.DefaultMongoPingTimeout,
"Mongo DB's ping timeout",
)
cmd.Flags().StringSliceVar(
Expand Down Expand Up @@ -285,51 +285,51 @@ func init() {
cmd.Flags().BoolVar(
&conf.Backend.UseDefaultProject,
"backend-use-default-project",
yorkie.DefaultUseDefaultProject,
server.DefaultUseDefaultProject,
"Whether to use the default project. Even if public key is not provided from the client, "+
"the default project will be used for the request.",
)
cmd.Flags().Uint64Var(
&conf.Backend.SnapshotThreshold,
"backend-snapshot-threshold",
yorkie.DefaultSnapshotThreshold,
server.DefaultSnapshotThreshold,
"Threshold that determines if changes should be sent with snapshot when the number "+
"of changes is greater than this value.",
)
cmd.Flags().Uint64Var(
&conf.Backend.SnapshotInterval,
"backend-snapshot-interval",
yorkie.DefaultSnapshotInterval,
server.DefaultSnapshotInterval,
"Interval of changes to create a snapshot.",
)
cmd.Flags().Uint64Var(
&conf.Backend.AuthWebhookMaxRetries,
"auth-webhook-max-retries",
yorkie.DefaultAuthWebhookMaxRetries,
server.DefaultAuthWebhookMaxRetries,
"Maximum number of retries for an authorization webhook.",
)
cmd.Flags().DurationVar(
&authWebhookMaxWaitInterval,
"auth-webhook-max-wait-interval",
yorkie.DefaultAuthWebhookMaxWaitInterval,
server.DefaultAuthWebhookMaxWaitInterval,
"Maximum wait interval for authorization webhook.",
)
cmd.Flags().IntVar(
&conf.Backend.AuthWebhookCacheSize,
"auth-webhook-cache-size",
yorkie.DefaultAuthWebhookCacheSize,
server.DefaultAuthWebhookCacheSize,
"The cache size of the authorization webhook.",
)
cmd.Flags().DurationVar(
&authWebhookCacheAuthTTL,
"auth-webhook-cache-auth-ttl",
yorkie.DefaultAuthWebhookCacheAuthTTL,
server.DefaultAuthWebhookCacheAuthTTL,
"TTL value to set when caching authorized webhook response.",
)
cmd.Flags().DurationVar(
&authWebhookCacheUnauthTTL,
"auth-webhook-cache-unauth-ttl",
yorkie.DefaultAuthWebhookCacheUnauthTTL,
server.DefaultAuthWebhookCacheUnauthTTL,
"TTL value to set when caching unauthorized webhook response.",
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/document/json/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type ElementPair struct {

// Root is a structure represents the root of JSON. It has a hash table of
// all JSON elements to find a specific element when applying remote changes
// received from agent.
// received from server.
//
// Every element has a unique time ticket at creation, which allows us to find
// a particular element.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import (
"github.com/yorkie-team/yorkie/api/converter"
"github.com/yorkie-team/yorkie/api/types"
"github.com/yorkie-team/yorkie/pkg/document/time"
"github.com/yorkie-team/yorkie/yorkie/backend"
"github.com/yorkie-team/yorkie/yorkie/logging"
"github.com/yorkie-team/yorkie/server/backend"
"github.com/yorkie-team/yorkie/server/logging"
)

// clusterServer is a normal server that processes the broadcast by the agent.
// clusterServer is a normal server that processes the broadcast by the server.
type clusterServer struct {
backend *backend.Backend
}
Expand Down
8 changes: 4 additions & 4 deletions yorkie/admin/server.go → server/admin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import (
"github.com/yorkie-team/yorkie/api"
"github.com/yorkie-team/yorkie/api/converter"
"github.com/yorkie-team/yorkie/api/types"
"github.com/yorkie-team/yorkie/yorkie/backend"
"github.com/yorkie-team/yorkie/yorkie/documents"
"github.com/yorkie-team/yorkie/yorkie/logging"
"github.com/yorkie-team/yorkie/yorkie/projects"
"github.com/yorkie-team/yorkie/server/backend"
"github.com/yorkie-team/yorkie/server/documents"
"github.com/yorkie-team/yorkie/server/logging"
"github.com/yorkie-team/yorkie/server/projects"
)

// ErrInvalidAdminPort occurs when the port in the config is invalid.
Expand Down
Loading

0 comments on commit d57f04c

Please sign in to comment.