mirror of
https://github.com/LBRYFoundation/herald.go.git
synced 2025-09-30 15:10:33 +00:00
fix github action and start added federated server code
This commit is contained in:
parent
6d79fc7dba
commit
7bac69af04
5 changed files with 34 additions and 10 deletions
2
.github/workflows/draft-release.yml
vendored
2
.github/workflows/draft-release.yml
vendored
|
@ -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
|
||||
|
|
2
.github/workflows/full-release.yml
vendored
2
.github/workflows/full-release.yml
vendored
|
@ -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
|
||||
- run: python3 scripts/version.py current --confirm --confirm --confirm
|
|
@ -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"]
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue