Top 3.4% dependent packages on proxy.golang.org
Top 3.5% dependent repos on proxy.golang.org
proxy.golang.org : github.com/creachadair/chirp
Package chirp implements the Chirp v0 protocol. Chirp is a lightweight remote procedure call protocol. Peers exchange binary packets over a shared reliable channel. The protocol is intended to be easy to implement in a variety of different languages and to perform efficiently over stream-oriented local transport mechanisms such as sockets and pipes. It uses a byte-oriented packet format with fixed headers to minimize the amount of bit-level manipulation necessary to encode and decode messages. The core type defined by this package is the Peer. Peers concurrently initiate and and service calls with another peer over a Channel. To create a new, unstarted peer: To start the service routine, call the Start method with a channel connected to another peer: The peer runs until Peer.Stop is called, the channel is closed by the remote peer, or a protocol fatal error occurs. Call Peer.Wait to wait for the peer to exit an return its status: The Channel interface defines the ability to send and receive packets as defined by the Chirp specification. A Channel implementation must allow concurrent use by one sender and one receiver. The channel package provides some basic implementations of this interface. A call is a request-response exchange between two peers, consisting of a request and a corresponding response. This is the primary communication between peers. The peer that initiates the call is the caller, the peer that responds is the callee. Calls may propagate in either direction. To define method handlers for inbound calls on the peer, use the Peer.Handle method to register a handler for the method ID: To issue a call to the remote peer, use the Peer.Call method: Errors returned by p.Call have concrete type *chirp.CallError. A method handler may "call back" to methods of the remote peer. To do so, the handler uses ContextPeer to obtain the local peer, and executes its Peer.Call method. This behaves as any other call made by the local peer: To invoke a handler directly on the local peer, use Peer.Exec: Exec does not send any packets to the remote peer. If the method handler invokes Peer.Call, that call also invokes its target locally. Errors reported by p.Exec have concrete type *chirp.CallError. To handle packet types other than Request, Response, and Cancel, the caller can use the Peer.SendPacket and Peer.HandlePacket methods. SendPacket allows the caller to send an arbitrary packet to the peer. Peers that do not understand a packet type will silently discard it (per the spec). HandlePacket registers a callback that will be invoked when a packet is received matching the specified type. If the callback reports an error or panics, it is treated as protocol fatal. Peers maintain a collection of metrics while running. Use the Peer.Metrics method to obtain an expvar.Map containing the metrics exported by the peer. By default, metrics are shared globally among all peers. The metrics currently exported by peers include: Additional metrics may be added in the future. It is safe for the caller to modify the metrics map to add, update, and remove entries. Using Peer.Detach "detaches" the metrics for a peer, and thereafter the metrics for that peer and its (recursive) clones will not affect the global metrics.
Registry
-
Source
- Documentation
- JSON
purl: pkg:golang/github.com/creachadair/chirp
License: BSD-3-Clause
Latest release: over 1 year ago
First release: almost 3 years ago
Namespace: github.com/creachadair
Dependent packages: 3
Dependent repositories: 2
Stars: 3 on GitHub
Forks: 1 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 28 days ago