-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract DocEvent into events Package (#1137)
Moved DocEvent from pubsub to events package to enable broader integration possibilities. This change prepares the system for future webhook and message broker integrations while maintaining existing pubsub functionality.
- Loading branch information
1 parent
eded115
commit a6fd4f0
Showing
15 changed files
with
146 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright 2025 The Yorkie Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// Package events defines the events that occur in the document and the client. | ||
package events | ||
|
||
import ( | ||
"github.com/yorkie-team/yorkie/api/types" | ||
"github.com/yorkie-team/yorkie/pkg/document/time" | ||
) | ||
|
||
// DocEventType represents the type of the DocEvent. | ||
type DocEventType string | ||
|
||
const ( | ||
// DocChangedEvent is an event indicating that document is being | ||
// modified by a change. | ||
DocChangedEvent DocEventType = "document-changed" | ||
|
||
// DocWatchedEvent is an event that occurs when document is watched | ||
// by other clients. | ||
DocWatchedEvent DocEventType = "document-watched" | ||
|
||
// DocUnwatchedEvent is an event that occurs when document is | ||
// unwatched by other clients. | ||
DocUnwatchedEvent DocEventType = "document-unwatched" | ||
|
||
// DocBroadcastEvent is an event that occurs when a payload is broadcasted | ||
// on a specific topic. | ||
DocBroadcastEvent DocEventType = "document-broadcast" | ||
) | ||
|
||
// DocEventBody includes additional data specific to the DocEvent. | ||
type DocEventBody struct { | ||
Topic string | ||
Payload []byte | ||
} | ||
|
||
// PayloadLen returns the size of the payload. | ||
func (b *DocEventBody) PayloadLen() int { | ||
return len(b.Payload) | ||
} | ||
|
||
// DocEvent represents an event that occurs in the document. | ||
type DocEvent struct { | ||
// Type is the type of the event. | ||
Type DocEventType | ||
|
||
// Publisher is the actor who published the event. | ||
Publisher *time.ActorID | ||
|
||
// DocRefKey is the key of the document that the event occurred. | ||
DocRefKey types.DocRefKey | ||
|
||
// Body includes additional data specific to the DocEvent. | ||
Body DocEventBody | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.