aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/doc.go
diff options
context:
space:
mode:
authorBas van Kervel <bas@ethdev.com>2016-03-29 21:07:40 +0800
committerBas van Kervel <bas@ethdev.com>2016-04-02 00:26:35 +0800
commitf7328c5ecbd1076582a71ef7bf436485f3868b1f (patch)
treea32f466f00306cb131bee254cbe14a4dcaa68973 /rpc/doc.go
parentfb578f4550a08617485d9146876489d1f3bb1b52 (diff)
downloadgo-tangerine-f7328c5ecbd1076582a71ef7bf436485f3868b1f.tar
go-tangerine-f7328c5ecbd1076582a71ef7bf436485f3868b1f.tar.gz
go-tangerine-f7328c5ecbd1076582a71ef7bf436485f3868b1f.tar.bz2
go-tangerine-f7328c5ecbd1076582a71ef7bf436485f3868b1f.tar.lz
go-tangerine-f7328c5ecbd1076582a71ef7bf436485f3868b1f.tar.xz
go-tangerine-f7328c5ecbd1076582a71ef7bf436485f3868b1f.tar.zst
go-tangerine-f7328c5ecbd1076582a71ef7bf436485f3868b1f.zip
rpc: add pub/sub support
Diffstat (limited to 'rpc/doc.go')
-rw-r--r--rpc/doc.go28
1 files changed, 6 insertions, 22 deletions
diff --git a/rpc/doc.go b/rpc/doc.go
index a2506ad58..c9dba3270 100644
--- a/rpc/doc.go
+++ b/rpc/doc.go
@@ -68,35 +68,19 @@ The package also supports the publish subscribe pattern through the use of subsc
A method that is considered eligible for notifications must satisfy the following criteria:
- object must be exported
- method must be exported
+ - first method argument type must be context.Context
- method argument(s) must be exported or builtin types
- method must return the tuple Subscription, error
-
An example method:
- func (s *BlockChainService) Head() (Subscription, error) {
- sub := s.bc.eventMux.Subscribe(ChainHeadEvent{})
- return v2.NewSubscription(sub), nil
- }
-
-This method will push all raised ChainHeadEvents to subscribed clients. If the client is only
-interested in every N'th block it is possible to add a criteria.
-
- func (s *BlockChainService) HeadFiltered(nth uint64) (Subscription, error) {
- sub := s.bc.eventMux.Subscribe(ChainHeadEvent{})
-
- criteria := func(event interface{}) bool {
- chainHeadEvent := event.(ChainHeadEvent)
- if chainHeadEvent.Block.NumberU64() % nth == 0 {
- return true
- }
- return false
- }
-
- return v2.NewSubscriptionFiltered(sub, criteria), nil
+ func (s *BlockChainService) NewBlocks(ctx context.Context) (Subscription, error) {
+ ...
}
Subscriptions are deleted when:
- the user sends an unsubscribe request
- - the connection which was used to create the subscription is closed
+ - the connection which was used to create the subscription is closed. This can be initiated
+ by the client and server. The server will close the connection on an write error or when
+ the queue of buffered notifications gets too big.
*/
package rpc