Skip to content

Commit

Permalink
Remove unnecessary codes
Browse files Browse the repository at this point in the history
  • Loading branch information
sejongk committed Sep 13, 2023
1 parent 5bf5466 commit 2223289
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
20 changes: 8 additions & 12 deletions api/types/auth_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,14 @@ type Method string

// Belows are the names of RPCs.
const (
ActivateClient Method = "ActivateClient"
DeactivateClient Method = "DeactivateClient"
AttachDocument Method = "AttachDocument"
DetachDocument Method = "DetachDocument"
RemoveDocument Method = "RemoveDocument"
PushPull Method = "PushPull"
WatchDocuments Method = "WatchDocuments"
Broadcast Method = "Broadcast"
SubscribeBroadcastEvent Method = "SubscribeBroadcastEvent"
UnsubscribeBroadcastEvent Method = "UnsubscribeBroadcastEvent"
ActivateClient Method = "ActivateClient"
DeactivateClient Method = "DeactivateClient"
AttachDocument Method = "AttachDocument"
DetachDocument Method = "DetachDocument"
RemoveDocument Method = "RemoveDocument"
PushPull Method = "PushPull"
WatchDocuments Method = "WatchDocuments"
Broadcast Method = "Broadcast"
)

// IsAuthMethod returns whether the given method can be used for authorization.
Expand All @@ -83,8 +81,6 @@ func AuthMethods() []Method {
PushPull,
WatchDocuments,
Broadcast,
SubscribeBroadcastEvent,
UnsubscribeBroadcastEvent,
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ func (c *Client) Watch(
go func() {
for {
select {
case e := <-doc.DocEvents():
case e := <-doc.Events():
t := PresenceChanged
if e.Type == document.WatchedEvent {
t = DocumentWatched
Expand Down
14 changes: 7 additions & 7 deletions pkg/document/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ type Document struct {
// is used to protect `doc.presences`.
clonePresences *innerpresence.Map

// docEvents is the channel to send events that occurred in the document.
docEvents chan DocEvent
// events is the channel to send events that occurred in the document.
events chan DocEvent

// broadcastRequests is the send-only channel to send broadcast requests.
broadcastRequests chan BroadcastRequest
Expand All @@ -104,7 +104,7 @@ type Document struct {
func New(key key.Key) *Document {
return &Document{
doc: NewInternalDocument(key),
docEvents: make(chan DocEvent, 1),
events: make(chan DocEvent, 1),
broadcastRequests: make(chan BroadcastRequest, 1),
broadcastResponses: make(chan error, 1),
broadcastEventHandlers: make(map[string]func(
Expand Down Expand Up @@ -181,7 +181,7 @@ func (d *Document) ApplyChangePack(pack *change.Pack) error {
}

for _, e := range events {
d.docEvents <- e
d.events <- e
}
}

Expand Down Expand Up @@ -360,9 +360,9 @@ func (d *Document) RemoveOnlineClient(clientID string) {
d.doc.RemoveOnlineClient(clientID)
}

// DocEvents returns the document events of this document.
func (d *Document) DocEvents() <-chan DocEvent {
return d.docEvents
// Events returns the document events of this document.
func (d *Document) Events() <-chan DocEvent {
return d.events
}

// BroadcastRequests returns the broadcast requests of this document.
Expand Down

0 comments on commit 2223289

Please sign in to comment.