Discover Packages
github.com/pojntfx/ltsrpc
pkg
rpc
package
Version:
v0.6.2-0...-fc8535a
Opens a new window with list of versions in this module.
Published: Jan 10, 2024
License: Apache-2.0
Opens a new window with license information.
Imports: 7
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Jump to ...
Documentation
Index
Constants
Variables
Functions
Types
type Message
type Options
type Registry
NewRegistry(local, ctx, options)
(r) ForRemotes(cb)
(r) LinkMessage(writeRequest, writeResponse, readRequest, readResponse, marshal, unmarshal)
(r) LinkStream(encode, decode, marshal, unmarshal)
type Request
type Response
Source Files
Documentation
Documentation
¶
View Source
const (
RemoteIDContextKey key = iota
DefaultResponseBufferLen = 1024
)
View Source
var (
ErrInvalidReturn = errors .New ("invalid return, can only return an error or a value and an error")
ErrInvalidArgs = errors .New ("invalid arguments, first argument needs to be a context.Context")
ErrCannotCallNonFunction = errors .New ("can not call non function")
)
type Message[T any ] struct {
Request *T `json:"request"`
Response *T `json:"response"`
}
type Options struct {
OnClientConnect func(remoteID string )
OnClientDisconnect func(remoteID string )
}
type Registry[R, T any ] struct {
}
func (r Registry [R, T]) LinkMessage(
writeRequest,
writeResponse func(b T) error ,
readRequest,
readResponse func() (T, error ),
marshal func(v any ) (T, error ),
unmarshal func(data T, v any ) error ,
) error
type Request[T any ] struct {
Call string `json:"call"`
Function string `json:"function"`
Args []T `json:"args"`
}
type Response[T any ] struct {
Call string `json:"call"`
Value T `json:"value"`
Err string `json:"err"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.