Bifrost is a grpc-based P2P network library
(In Norse mythology, Bifrรถst is a burning rainbow bridge that reaches between Midgard and Asgard, the realm of the gods.)
go get -u github.com/DE-labtory/bifrost
Server
import (
"github.com/DE-labtory/bifrost/pb"
"github.com/DE-labtory/bifrost/server"
)
// connection control
ConnectionStore := bifrost.NewConnectionStore()
// server listen
s := server.New(bifrost.KeyOpts{PriKey: priKey, PubKey: pubKey})
server.Listen(_gRPCatewayIP_)
Client
import (
"github.com/DE-labtory/bifrost/client"
)
connection, err := client.Dial(command.Address, clientOpt, grpcOpt) //ํํ cli ์์ ์ด๋ฃจ์ด์ง
connection.send(payload []byte, protocol string, successCallBack func(interface{}), errCallBack func(error)) //connection GrpcConnection
bifrost ๊ฐ grpc ์๋น์ค๋ฅผ ๊ตฌ์ถํ๊ธฐ ์ํด stream.proto file ์ ์์ฑํ์์ผ๋ฉฐ, ์ด๋ protoc ์ ์ํด compile ๋์ด go ์ฝ๋๋ก ๋ณํ๋๋ค. stream.proto file ์ ๋ํด ๊ฐ๋จํ ์๊ฐํ์๋ฉด StreamService ๋ผ๋ ๊ตฌ์กฐ์ฒด๋ฅผ ๊ธฐ๋ฐ์ผ๋ก BifrostStream์ด๋ผ๋ ํจ์๋ฅผ ๊ฐ์ง๋ฉฐ, Envelope ๋ผ๋ ์๋ฃํ์ ์ถ๊ฐ๋ก ๊ตฌ์ฑํ๋ค.
์๋ฒ์ธก์์ RegisterStreamServiceServer
๋ฅผ ํตํด ์๋ฒ๋ฅผ ๋ฑ๋กํ๊ณ ํด๋ผ์ด์ธํธ ์ธก์์ NewStreamServiceClient
๋ฅผ ํตํด streamServiceClient ๊ฐ์ฒด๋ฅผ ์์ฑํ๊ณ , streamServiceClient.BifrostStream
์ ํธ์ถํ๋ ๋ฐฉ์์ผ๋ก Envelop ๋ฅผ ์ก์์ ํ๋ค.
Bifrost source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file.