Skip to content

Commit

Permalink
multi: faraday rename
Browse files Browse the repository at this point in the history
  • Loading branch information
carlaKC committed Mar 30, 2020
1 parent cf4fc1f commit df836c2
Show file tree
Hide file tree
Showing 30 changed files with 239 additions and 239 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/governator
/gvncli
/faraday
/frcli
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ FROM golang:1.13-alpine as builder
# queries required to connect to linked containers succeed.
ENV GODEBUG netdns=cgo

ADD . /go/src/github.com/lightninglabs/governator
ADD . /go/src/github.com/lightninglabs/faraday

# Install dependencies and build the binaries.
RUN apk add --no-cache --update alpine-sdk \
git \
make \
gcc \
&& cd /go/src/github.com/lightninglabs/governator \
&& cd /go/src/github.com/lightninglabs/faraday \
&& make \
&& make install

Expand All @@ -24,12 +24,12 @@ RUN apk --no-cache add \
ca-certificates

# Copy the binaries from the builder image.
COPY --from=builder /go/bin/governator /bin/
COPY --from=builder /go/bin/gvncli /bin/
COPY --from=builder /go/bin/faraday /bin/
COPY --from=builder /go/bin/frcli /bin/

# Expose governator ports (rpc).
# Expose faraday ports (rpc).
EXPOSE 8465

# Specify the start command and entrypoint as the governator daemon.
ENTRYPOINT ["governator"]
# Specify the start command and entrypoint as the faraday daemon.
ENTRYPOINT ["faraday"]

24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PKG := github.com/lightninglabs/governator
ESCPKG := github.com\/lightninglabs\/governator
PKG := github.com/lightninglabs/faraday
ESCPKG := github.com\/lightninglabs\/faraday

LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
GOVERALLS_PKG := github.com/mattn/goveralls
Expand Down Expand Up @@ -59,14 +59,14 @@ $(GOACC_BIN):
# ============

build:
@$(call print, "Building governator.")
$(GOBUILD) $(LDFLAGS) $(PKG)/cmd/governator
$(GOBUILD) $(LDFLAGS) $(PKG)/cmd/gvncli
@$(call print, "Building faraday.")
$(GOBUILD) $(LDFLAGS) $(PKG)/cmd/faraday
$(GOBUILD) $(LDFLAGS) $(PKG)/cmd/frcli

install:
@$(call print, "Installing governator.")
$(GOINSTALL) $(LDFLAGS) $(PKG)/cmd/governator
$(GOINSTALL) $(LDFLAGS) $(PKG)/cmd/gvncli
@$(call print, "Installing faraday.")
$(GOINSTALL) $(LDFLAGS) $(PKG)/cmd/faraday
$(GOINSTALL) $(LDFLAGS) $(PKG)/cmd/frcli

scratch: build

Expand Down Expand Up @@ -94,7 +94,7 @@ goveralls: $(GOVERALLS_BIN)

rpc:
@$(call print, "Compiling protos.")
cd ./gvnrpc; ./gen_protos.sh
cd ./frdrpc; ./gen_protos.sh

travis-race: lint unit-race

Expand Down Expand Up @@ -123,12 +123,12 @@ lint: $(LINT_BIN)

list:
@$(call print, "Listing commands.")
@$(MAKE) -qp | \
@$(MAKE) -qp | \
awk -F':' '/^[a-zA-Z0-9][^$$#\/\t=]*:([^=]|$$)/ {split($$1,A,/ /);for(i in A)print A[i]}' | \
grep -v Makefile | \
sort
clean:
@$(call print, "Cleaning source.$(NC)")
$(RM) ./governator
$(RM) ./gvncli
$(RM) ./faraday
$(RM) ./frcli
$(RM) coverage.txt
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# governator
# faraday

[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/lightninglabs/governator/blob/master/LICENSE)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/lightninglabs/faraday/blob/master/LICENSE)

The governator is an external service intended to be run in conjunction with the [lnd](https://github.com/lightningnetwork/lnd) implementation of the [Lightning Network](https://lightning.network). It queries LND for information about its existing channels and provides channel close recommendations if channels are under-performing.
Faraday is an external service intended to be run in conjunction with the [lnd](https://github.com/lightningnetwork/lnd) implementation of the [Lightning Network](https://lightning.network). It queries LND for information about its existing channels and provides channel close recommendations if channels are under-performing.

## Installation
A [Makefile](https://github.com/lightninglabs/governator/blob/master/Makefile) is provided. To install governator and al its dependencies, run:
A [Makefile](https://github.com/lightninglabs/faraday/blob/master/Makefile) is provided. To install faraday and all its dependencies, run:

```
go get -d github.com/lightninglabs/governator
cd $GOPATH/src/github.com/lightninglabs/governator
go get -d github.com/lightninglabs/faraday
cd $GOPATH/src/github.com/lightninglabs/faraday
make && make install
```

Expand All @@ -21,28 +21,28 @@ make check
```

## Usage
Governator connects to a single instance of lnd. It requires access to a macaroon with read permissions and a valid TLS certificate. It will attempt to use the default lnd values if no command line flags are specified.
Faraday connects to a single instance of lnd. It requires access to a macaroon with read permissions and a valid TLS certificate. It will attempt to use the default lnd values if no command line flags are specified.
```
./governator \
./faraday \
--macaroondir={directory containing macaroon} \
--macaroonfile={macaroon with read permissions} \
--tlscertpath={path to lnd cert} \
--rpserver={host:port of lnd's rpserver}
```

By default, governator runs on mainnet. The `--testnet`, `--simnet` or `--regtest` flags can be used to run in test environments.
By default, faraday runs on mainnet. The `--testnet`, `--simnet` or `--regtest` flags can be used to run in test environments.

#### RPCServer
Governator serves requests over grpc by default on `localhost:8465`. This default can be overwritten:
Faraday serves requests over grpc by default on `localhost:8465`. This default can be overwritten:
```
--rpclisten={host:port to listen for requests}
```

#### Cli Tool
The RPC server can be conveniently accessed using a command line tool.
1. Run governator as detailed above
1. Run faraday as detailed above
```
./gvncli {command}
./frcli {command}
```

##### Commands
Expand All @@ -52,7 +52,7 @@ The RPC server can be conveniently accessed using a command line tool.
- `threshold`: close recommendations based on thresholds a variety of metrics.

#### Metrics currently tracked
The following metrics are tracked in governator and exposed via `insights` and used for `outliers` and `threshold` close recommendations.
The following metrics are tracked in faraday and exposed via `insights` and used for `outliers` and `threshold` close recommendations.
- Uptime
- Revenue
- Total Volume
Expand Down
4 changes: 2 additions & 2 deletions cmd/governator/log.go → cmd/faraday/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"github.com/btcsuite/btclog"
"github.com/lightninglabs/governator"
"github.com/lightninglabs/faraday"
"github.com/lightningnetwork/lnd/build"
)

Expand All @@ -13,7 +13,7 @@ var (

func init() {
setSubLogger("GVNR", log, nil)
addSubLogger(governator.Subsystem, governator.UseLogger)
addSubLogger(faraday.Subsystem, faraday.UseLogger)
}

// addSubLogger is a helper method to conveniently create and register the
Expand Down
6 changes: 3 additions & 3 deletions cmd/governator/main.go → cmd/faraday/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package main
import (
"os"

"github.com/lightninglabs/governator"
"github.com/lightninglabs/faraday"
)

// main calls the "real" main function in a nested manner so that defers will be
// properly executed if os.Exit() is called.
func main() {
if err := governator.Main(); err != nil {
log.Infof("Error starting governator: %v", err)
if err := faraday.Main(); err != nil {
log.Infof("Error starting faraday: %v", err)
}

os.Exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"context"

"github.com/lightninglabs/governator/gvnrpc"
"github.com/lightninglabs/faraday/frdrpc"
"github.com/urfave/cli"
)

Expand All @@ -18,7 +18,7 @@ var channelInsightsCommand = cli.Command{
// insightsResp is used to display additional information that is calculated
// from the channel insight in the cli response.
type insightsResp struct {
*gvnrpc.ChannelInsight
*frdrpc.ChannelInsight
UptimeRatio float64 `json:"uptime_ratio"`
RevenuePerConfirmation float64 `json:"revenue_per_conf_msat"`
VolumePerConfirmation float64 `json:"volume_per_conf_msat"`
Expand All @@ -32,7 +32,7 @@ func queryChannelInsights(ctx *cli.Context) error {

rpcCtx := context.Background()
resp, err := client.ChannelInsights(
rpcCtx, &gvnrpc.ChannelInsightsRequest{},
rpcCtx, &frdrpc.ChannelInsightsRequest{},
)
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"time"

"github.com/lightninglabs/governator/gvnrpc"
"github.com/lightninglabs/faraday/frdrpc"
"github.com/urfave/cli"
)

Expand Down Expand Up @@ -110,8 +110,8 @@ func queryThresholdRecommendations(ctx *cli.Context) error {

// Set monitored value from cli values, this value will always be
// non-zero because the flag has a default.
req := &gvnrpc.ThresholdRecommendationsRequest{
RecRequest: &gvnrpc.CloseRecommendationRequest{
req := &frdrpc.ThresholdRecommendationsRequest{
RecRequest: &frdrpc.CloseRecommendationRequest{
MinimumMonitored: ctx.Int64("min_monitored"),
},
}
Expand All @@ -120,23 +120,23 @@ func queryThresholdRecommendations(ctx *cli.Context) error {
switch {
case ctx.IsSet("uptime"):
req.ThresholdValue = float32(ctx.Float64("uptime"))
req.RecRequest.Metric = gvnrpc.CloseRecommendationRequest_UPTIME
req.RecRequest.Metric = frdrpc.CloseRecommendationRequest_UPTIME

case ctx.IsSet("revenue"):
req.ThresholdValue = float32(ctx.Float64("revenue"))
req.RecRequest.Metric = gvnrpc.CloseRecommendationRequest_REVENUE
req.RecRequest.Metric = frdrpc.CloseRecommendationRequest_REVENUE

case ctx.IsSet("incoming"):
req.ThresholdValue = float32(ctx.Float64("incoming"))
req.RecRequest.Metric = gvnrpc.CloseRecommendationRequest_INCOMING_VOLUME
req.RecRequest.Metric = frdrpc.CloseRecommendationRequest_INCOMING_VOLUME

case ctx.IsSet("outgoing"):
req.ThresholdValue = float32(ctx.Float64("outgoing"))
req.RecRequest.Metric = gvnrpc.CloseRecommendationRequest_OUTGOING_VOLUME
req.RecRequest.Metric = frdrpc.CloseRecommendationRequest_OUTGOING_VOLUME

case ctx.IsSet("volume"):
req.ThresholdValue = float32(ctx.Float64("volume"))
req.RecRequest.Metric = gvnrpc.CloseRecommendationRequest_TOTAL_VOLUME
req.RecRequest.Metric = frdrpc.CloseRecommendationRequest_TOTAL_VOLUME

default:
return fmt.Errorf("threshold required")
Expand Down Expand Up @@ -170,8 +170,8 @@ func queryOutlierRecommendations(ctx *cli.Context) error {
// outlier multiplier will be overwritten if the user provided it, and
// the monitored value will always be non-zero because the flag has a
// default value.
req := &gvnrpc.OutlierRecommendationsRequest{
RecRequest: &gvnrpc.CloseRecommendationRequest{
req := &frdrpc.OutlierRecommendationsRequest{
RecRequest: &frdrpc.CloseRecommendationRequest{
MinimumMonitored: ctx.Int64("min_monitored"),
},
OutlierMultiplier: float32(defaultOutlierMultiplier),
Expand All @@ -185,19 +185,19 @@ func queryOutlierRecommendations(ctx *cli.Context) error {
// Set metric based on uptime or revenue flags.
switch {
case ctx.IsSet("uptime"):
req.RecRequest.Metric = gvnrpc.CloseRecommendationRequest_UPTIME
req.RecRequest.Metric = frdrpc.CloseRecommendationRequest_UPTIME

case ctx.IsSet("revenue"):
req.RecRequest.Metric = gvnrpc.CloseRecommendationRequest_REVENUE
req.RecRequest.Metric = frdrpc.CloseRecommendationRequest_REVENUE

case ctx.IsSet("incoming_volume"):
req.RecRequest.Metric = gvnrpc.CloseRecommendationRequest_INCOMING_VOLUME
req.RecRequest.Metric = frdrpc.CloseRecommendationRequest_INCOMING_VOLUME

case ctx.IsSet("outgoing_volume"):
req.RecRequest.Metric = gvnrpc.CloseRecommendationRequest_OUTGOING_VOLUME
req.RecRequest.Metric = frdrpc.CloseRecommendationRequest_OUTGOING_VOLUME

case ctx.IsSet("volume"):
req.RecRequest.Metric = gvnrpc.CloseRecommendationRequest_TOTAL_VOLUME
req.RecRequest.Metric = frdrpc.CloseRecommendationRequest_TOTAL_VOLUME

default:
return fmt.Errorf("uptime, revenue or volume realted flag " +
Expand Down
10 changes: 5 additions & 5 deletions cmd/gvncli/main.go → cmd/frcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"os"

"github.com/lightninglabs/governator"
"github.com/lightninglabs/faraday"
"github.com/urfave/cli"
)

Expand All @@ -14,14 +14,14 @@ var (

func main() {
app := cli.NewApp()
app.Name = "gvncli"
app.Usage = "command line tool for governator"
app.Version = governator.Version()
app.Name = "frcli"
app.Usage = "command line tool for faraday"
app.Version = faraday.Version()
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "rpcserver",
Value: defaultRPCHostPort,
Usage: "host:port of governator",
Usage: "host:port of faraday",
},
}
app.Commands = []cli.Command{
Expand Down
4 changes: 2 additions & 2 deletions cmd/gvncli/revenue_report.go → cmd/frcli/revenue_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"context"

"github.com/lightninglabs/governator/gvnrpc"
"github.com/lightninglabs/faraday/frdrpc"
"github.com/urfave/cli"
)

Expand Down Expand Up @@ -48,7 +48,7 @@ func queryRevenueReport(ctx *cli.Context) error {

// Set start and end times from user specified values, defaulting
// to zero if they are not set.
req := &gvnrpc.RevenueReportRequest{
req := &frdrpc.RevenueReportRequest{
StartTime: uint64(ctx.Int64("start_time")),
EndTime: uint64(ctx.Int64("end_time")),
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/gvncli/utils.go → cmd/frcli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net"
"os"

"github.com/lightninglabs/governator/gvnrpc"
"github.com/lightninglabs/faraday/frdrpc"
"github.com/lightninglabs/protobuf-hex-display/jsonpb"
"github.com/lightninglabs/protobuf-hex-display/proto"
"github.com/lightningnetwork/lnd/lncfg"
Expand All @@ -24,7 +24,7 @@ var (

// fatal logs and error and exits.
func fatal(err error) {
_, _ = fmt.Fprintf(os.Stderr, "[gvncli] %v\n", err)
_, _ = fmt.Fprintf(os.Stderr, "[frcli] %v\n", err)
os.Exit(1)
}

Expand Down Expand Up @@ -57,8 +57,8 @@ func printJSON(resp interface{}) {
_, _ = out.WriteTo(os.Stdout)
}

// getClient returns a governator client.
func getClient(ctx *cli.Context) (gvnrpc.GovernatorServerClient, func()) {
// getClient returns a faraday client.
func getClient(ctx *cli.Context) (frdrpc.FaradayServerClient, func()) {
conn := getClientConn(ctx)

cleanUp := func() {
Expand All @@ -67,7 +67,7 @@ func getClient(ctx *cli.Context) (gvnrpc.GovernatorServerClient, func()) {
}
}

return gvnrpc.NewGovernatorServerClient(conn), cleanUp
return frdrpc.NewFaradayServerClient(conn), cleanUp
}

// getClientConn gets a client connection to the address provided by the
Expand Down
Loading

0 comments on commit df836c2

Please sign in to comment.