fix github action and start added federated server code

This commit is contained in:
Jeffrey Picard 2021-07-23 11:24:37 -04:00
parent 6d79fc7dba
commit 7bac69af04
5 changed files with 34 additions and 10 deletions

View file

@ -30,4 +30,4 @@ jobs:
cd cd
- run: pip install grpcio grpcio-tools github3.py - run: pip install grpcio grpcio-tools github3.py
- run: go get github.com/golang/protobuf/protoc-gen-go google.golang.org/grpc/cmd/protoc-gen-go-grpc - run: go get github.com/golang/protobuf/protoc-gen-go google.golang.org/grpc/cmd/protoc-gen-go-grpc
- run: python3 scripts/version.py current --commit # creates a draft release - run: python3 scripts/version.py current --confirm # creates a draft release

View file

@ -31,4 +31,4 @@ jobs:
cd cd
- run: pip install grpcio grpcio-tools github3.py - run: pip install grpcio grpcio-tools github3.py
- run: go get github.com/golang/protobuf/protoc-gen-go google.golang.org/grpc/cmd/protoc-gen-go-grpc - run: go get github.com/golang/protobuf/protoc-gen-go google.golang.org/grpc/cmd/protoc-gen-go-grpc
- run: python3 scripts/version.py current --commit --commit --commit - run: python3 scripts/version.py current --confirm --confirm --confirm

View file

@ -1,6 +0,0 @@
FROM debian:10-slim
EXPOSE 50051
RUN apt-get update && apt-get install curl -y
RUN curl -L -o /hub https://github.com/lbryio/hub/releases/download/v0.2021.06.14-beta/hub && chmod +x /hub
ENTRYPOINT ["/hub", "serve", "--dev"]

View file

@ -50,10 +50,17 @@ Install Go 1.14+
Download `protoc` from https://github.com/protocolbuffers/protobuf/releases and make sure it is Download `protoc` from https://github.com/protocolbuffers/protobuf/releases and make sure it is
executable and in your path. executable and in your path.
Install Go plugin for protoc: Install Go plugin for protoc and python:
``` ```
go get google.golang.org/protobuf/cmd/protoc-gen-go google.golang.org/grpc/cmd/protoc-gen-go-grpc go get google.golang.org/protobuf/cmd/protoc-gen-go google.golang.org/grpc/cmd/protoc-gen-go-grpc
pip install grpcio grpcio-tools github3.py
```
Lastly the hub needs protobuf version 3.17.1, it may work with newer version but this is what it's built with, on ubuntu systems you'll have to install this from source see the GitHub actions in `.github/workflows` for an example of this.
```
https://github.com/protocolbuffers/protobuf/releases/download/v3.17.1/protobuf-all-3.17.1.tar.gz
``` ```
If you can run `./protobuf/build.sh` without errors, you have `go` and `protoc` installed correctly. If you can run `./protobuf/build.sh` without errors, you have `go` and `protoc` installed correctly.

View file

@ -24,9 +24,17 @@ type Server struct {
MultiSpaceRe *regexp.Regexp MultiSpaceRe *regexp.Regexp
WeirdCharsRe *regexp.Regexp WeirdCharsRe *regexp.Regexp
EsClient *elastic.Client EsClient *elastic.Client
Servers []*FederatedServer
pb.UnimplementedHubServer pb.UnimplementedHubServer
} }
type FederatedServer struct {
Address string
Port string
Ts time.Time
Ping int //?
}
const majorVersion = 0 const majorVersion = 0
const ( const (
@ -167,12 +175,20 @@ func MakeHubServer(args *Args) *Server {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
self := &FederatedServer{
Address: "127.0.0.1",
Port: args.Port,
Ts: time.Now(),
Ping: 0,
}
servers := make([]*FederatedServer, 10)
servers = append(servers, self)
s := &Server { s := &Server {
GrpcServer: grpcServer, GrpcServer: grpcServer,
Args: args, Args: args,
MultiSpaceRe: multiSpaceRe, MultiSpaceRe: multiSpaceRe,
WeirdCharsRe: weirdCharsRe, WeirdCharsRe: weirdCharsRe,
Servers: servers,
} }
return s return s
@ -200,6 +216,13 @@ func (s *Server) PromethusEndpoint(port string, endpoint string) error {
return nil return nil
} }
func (s *Server) EHLO(context context.Context, args *FederatedServer) (*FederatedServer, error) {
s.RecordMetrics("federated_servers", nil)
s.Servers = append(s.Servers, args)
return s.Servers[0], nil
}
func (s *Server) Ping(context context.Context, args *pb.NoParamsThisIsSilly) (*wrapperspb.StringValue, error) { func (s *Server) Ping(context context.Context, args *pb.NoParamsThisIsSilly) (*wrapperspb.StringValue, error) {
s.RecordMetrics("pings", nil) s.RecordMetrics("pings", nil)
return &wrapperspb.StringValue{Value: "Hello, wolrd!"}, nil return &wrapperspb.StringValue{Value: "Hello, wolrd!"}, nil