From 7bac69af049b9fb10d312d9d1483df500b4a0044 Mon Sep 17 00:00:00 2001 From: Jeffrey Picard Date: Fri, 23 Jul 2021 11:24:37 -0400 Subject: [PATCH] fix github action and start added federated server code --- .github/workflows/draft-release.yml | 2 +- .github/workflows/full-release.yml | 2 +- dev.dockerfile | 6 ------ readme.md | 9 ++++++++- server/server.go | 25 ++++++++++++++++++++++++- 5 files changed, 34 insertions(+), 10 deletions(-) delete mode 100644 dev.dockerfile diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index 4ec3e43..fe24617 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -30,4 +30,4 @@ jobs: cd - 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: python3 scripts/version.py current --commit # creates a draft release + - run: python3 scripts/version.py current --confirm # creates a draft release diff --git a/.github/workflows/full-release.yml b/.github/workflows/full-release.yml index 725f7a6..cdb55ca 100644 --- a/.github/workflows/full-release.yml +++ b/.github/workflows/full-release.yml @@ -31,4 +31,4 @@ jobs: cd - 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: python3 scripts/version.py current --commit --commit --commit \ No newline at end of file + - run: python3 scripts/version.py current --confirm --confirm --confirm \ No newline at end of file diff --git a/dev.dockerfile b/dev.dockerfile deleted file mode 100644 index be73f0e..0000000 --- a/dev.dockerfile +++ /dev/null @@ -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"] diff --git a/readme.md b/readme.md index 918e1b7..a53c98a 100644 --- a/readme.md +++ b/readme.md @@ -50,10 +50,17 @@ Install Go 1.14+ Download `protoc` from https://github.com/protocolbuffers/protobuf/releases and make sure it is 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 +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. diff --git a/server/server.go b/server/server.go index 3e90bf1..09061a4 100644 --- a/server/server.go +++ b/server/server.go @@ -24,9 +24,17 @@ type Server struct { MultiSpaceRe *regexp.Regexp WeirdCharsRe *regexp.Regexp EsClient *elastic.Client + Servers []*FederatedServer pb.UnimplementedHubServer } +type FederatedServer struct { + Address string + Port string + Ts time.Time + Ping int //? +} + const majorVersion = 0 const ( @@ -167,12 +175,20 @@ func MakeHubServer(args *Args) *Server { if err != nil { 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 { GrpcServer: grpcServer, Args: args, MultiSpaceRe: multiSpaceRe, WeirdCharsRe: weirdCharsRe, + Servers: servers, } return s @@ -200,6 +216,13 @@ func (s *Server) PromethusEndpoint(port string, endpoint string) error { 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) { s.RecordMetrics("pings", nil) return &wrapperspb.StringValue{Value: "Hello, wolrd!"}, nil