good morning!!!!

Skip to content
Snippets Groups Projects
Commit df7736a3 authored by a's avatar a
Browse files

jay zon r pee see

parent a5154430
No related branches found
No related tags found
2 merge requests!15Draft: V2,!13Draft: Move Openrpc Package
...@@ -10,39 +10,43 @@ import ( ...@@ -10,39 +10,43 @@ import (
// to make the repo cleaner, we export everything here. this way the packages dont need to ever import this // to make the repo cleaner, we export everything here. this way the packages dont need to ever import this
type ( type (
// Conn // Conn is used to make requests to jsonrpc2 servers
Conn = codec.Conn Conn = codec.Conn
// Handler // Handler is the equivilant of http.Handler, but for jsonrpc.
Handler = codec.Handler Handler = codec.Handler
// HandlerFunc // HandlerFunc is a Handler that exists as a function
HandlerFunc = codec.HandlerFunc HandlerFunc = codec.HandlerFunc
// ResponseWriter // ResponseWriter is used to write responses to the request
ResponseWriter = codec.ResponseWriter ResponseWriter = codec.ResponseWriter
// StreamingConn // StreamingConn is a conn that supports streaming methods
StreamingConn = codec.Conn StreamingConn = codec.Conn
) )
type ( type (
// BatchElem // BatchElem is an element of a batch request
BatchElem = codec.BatchElem BatchElem = codec.BatchElem
) )
var ( var (
ContextWithConn = codec.ContextWithConn // ContextWithConn will attach a conn to the context
ContextWithConn = codec.ContextWithConn
// ContextWithPeerInfo will attach a peerinfo to the context
ContextWithPeerInfo = server.ContextWithPeerInfo ContextWithPeerInfo = server.ContextWithPeerInfo
ConnFromContext = codec.ConnFromContext // ConnFromContext will retrieve a conn from context
ConnFromContext = codec.ConnFromContext
// PeerInfoFromContext will retrieve a peerinfo from context
PeerInfoFromContext = server.PeerInfoFromContext PeerInfoFromContext = server.PeerInfoFromContext
) )
// Do // Do will use the conn to perform a jsonrpc2 call.
func Do[T any](ctx context.Context, c Conn, method string, args any) (*T, error) { func Do[T any](ctx context.Context, c Conn, method string, args any) (*T, error) {
return codec.Do[T](ctx, c, method, args) return codec.Do[T](ctx, c, method, args)
} }
// Call // Call will use the conn to perform a jsonrpc2 call, except the args will be encoded as an array of arguments.
func Call[T any](ctx context.Context, c Conn, method string, args ...any) (*T, error) { func Call[T any](ctx context.Context, c Conn, method string, args ...any) (*T, error) {
return codec.Call[T](ctx, c, method, args...) return codec.Call[T](ctx, c, method, args...)
} }
// CallInto // CallInto is the same as Call, except instead of returning, you provide a pointer to the result
var CallInto = codec.CallInto var CallInto = codec.CallInto
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment