Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

zhuyie/bidirpc

Open more actions menu

Repository files navigation

bidirpc

GoDoc MIT licensed Build Status Coverage Statusd

bidirpc is a simple bi-direction RPC library.

Usage

import (
    "io"
    "log"

    "github.com/zhuyie/bidirpc"
)

type YourService struct{}

var conn io.ReadWriteCloser

// Create a registry, and register your available services, YourService follows
// net/rpc semantics
registry := bidirpc.NewRegistry()
registry.Register(&YourService{})

// TODO: Establish your connection before passing it to the session

// Create a new session
session, err := bidirpc.NewSession(conn, bidirpc.Yin, registry, 0)
if err != nil {
	log.Fatal(err)
}
// Clean up session resources
defer func() {
	if err := session.Close(); err != nil {
		log.Fatal(err)
	}
}()

// Start the event loop, this is a blocking call, so place it in a goroutine
// if you need to move on.  The call will return when the connection is
// terminated.
if err = session.Serve(); err != nil {
	log.Fatal(err)
}

About

bidirpc is a simple bi-direction RPC library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.