aboutsummaryrefslogtreecommitdiff
path: root/jsonrpc/message
diff options
context:
space:
mode:
authorhozan23 <hozan23@karyontech.net>2024-06-23 15:57:43 +0200
committerhozan23 <hozan23@karyontech.net>2024-07-09 11:46:03 +0200
commit6355144b8c3514cccc5c2ab4f7c4fd8e76a1a9fc (patch)
tree3c31e350c8da79198f6127398905461addccef1e /jsonrpc/message
parent223d80fa52d3efd2909b7061e3c42a0ed930b4ff (diff)
Fix the issue with message dispatcher and channels
Resolved a previous error where each subscription would create a new channel with the fixed buffer size. This caused blocking when the channel buffer was full, preventing the client from handling additional messages. Now, there is a `subscriptions` struct that holds a queue for receiving notifications, ensuring the notify function does not block.
Diffstat (limited to 'jsonrpc/message')
-rw-r--r--jsonrpc/message/message.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/jsonrpc/message/message.go b/jsonrpc/message/message.go
index ff68da2..b01c05d 100644
--- a/jsonrpc/message/message.go
+++ b/jsonrpc/message/message.go
@@ -26,7 +26,7 @@ type Request struct {
type Response struct {
JSONRPC string `json:"jsonrpc"` // JSON-RPC version, typically "2.0".
ID *RequestID `json:"id,omitempty"` // Unique identifier matching the request ID, can be null for notifications.
- Result *json.RawMessage `json:"result,omitempty"` // Result of the request if it was successful.
+ Result json.RawMessage `json:"result,omitempty"` // Result of the request if it was successful.
Error *Error `json:"error,omitempty"` // Error object if the request failed.
}
@@ -34,13 +34,13 @@ type Response struct {
type Notification struct {
JSONRPC string `json:"jsonrpc"` // JSON-RPC version, typically "2.0".
Method string `json:"method"` // The name of the method to be invoked.
- Params *json.RawMessage `json:"params,omitempty"` // Optional parameters for the method.
+ Params json.RawMessage `json:"params,omitempty"` // Optional parameters for the method.
}
// NotificationResult represents the result of a subscription notification.
// It includes the result and the subscription ID that triggered the notification.
type NotificationResult struct {
- Result *json.RawMessage `json:"result,omitempty"` // Result data of the notification.
+ Result json.RawMessage `json:"result,omitempty"` // Result data of the notification.
Subscription SubscriptionID `json:"subscription"` // ID of the subscription that triggered the notification.
}
@@ -49,7 +49,7 @@ type NotificationResult struct {
type Error struct {
Code int `json:"code"` // Error code indicating the type of error.
Message string `json:"message"` // Human-readable error message.
- Data *json.RawMessage `json:"data,omitempty"` // Optional additional data about the error.
+ Data json.RawMessage `json:"data,omitempty"` // Optional additional data about the error.
}
func (req *Request) String() string {
@@ -57,11 +57,11 @@ func (req *Request) String() string {
}
func (res *Response) String() string {
- return fmt.Sprintf("{JSONRPC: %s, ID: %s, RESULT: %s, ERROR: %v}", res.JSONRPC, *res.ID, *res.Result, res.Error)
+ return fmt.Sprintf("{JSONRPC: %s, ID: %v, RESULT: %v, ERROR: %v}", res.JSONRPC, res.ID, res.Result, res.Error)
}
func (nt *Notification) String() string {
- return fmt.Sprintf("{JSONRPC: %s, METHOD: %s, PARAMS: %s}", nt.JSONRPC, nt.Method, *nt.Params)
+ return fmt.Sprintf("{JSONRPC: %s, METHOD: %s, PARAMS: %s}", nt.JSONRPC, nt.Method, nt.Params)
}
func (err *Error) String() string {