Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update messager.toml and README.md #139

Merged
merged 1 commit into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 82 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,96 @@ messager is a component used to manage local messages, with the purpose of savin
- 🔲 Enhanced API Security
- 🔲 Rich and flexible message sorting options
- 🔲 Message-delivery assuring: Auto replace parameters and resend messages whenever there is a failure
- ❓ Manage messages through a multi-tenant pattern by wallet name


## Getting Start

build binary
```sh
git clone
make deps
git clone https://github.com/filecoin-project/venus-messager.git
make
```

edit messager.toml config file, edit node url and token
## Config

```
[api]
Address = "/ip4/0.0.0.0/tcp/39812"

[db]
# support sqlite and mysql
type = "sqlite"

[db.mysql]
connMaxLifeTime = "1m0s"
connectionString = "" # eg. root:password@(127.0.0.1:3306)/messager?parseTime=true&loc=Local
debug = false
maxIdleConn = 10
maxOpenConn = 10

[db.sqlite]
debug = false
file = "./message.db"

[gateway]
# enable gateway
remoteEnable = true
# gateway token, generate by auth server
token = ""
# gateway url
url = "/ip4/127.0.0.1/tcp/45132"

[gateway.cfg]
RequestQueueSize = 30
RequestTimeout = "5m0s"

[jwt]
# auth server url, not connect when empty
authURL = "http://127.0.0.1:8989"

[jwt.local]
# JWT token, generate by secret
secret = ""
# hex JWT secret, randam generate first init
token = ""

[log]
# default log level
level = "info"
# log output file
path = "messager.log"

[messageService]
# skip process head
skipProcessHead = false
# skip push message
skipPushMessage = false
# file used to store tipset
tipsetFilePath = "./tipset.json"

[messageState]
CleanupInterval = 86400
DefaultExpiration = 259200
backTime = 86400

[node]
# node token, generate by auth server
token = ""
# node url
url = "/ip4/127.0.0.1/tcp/3453"

[rateLimit]
redis = "" # eg. 127.0.0.1:6379

[tracing]
JaegerEndpoint = "" # eg. 1270.0.0.1:6831
# enable trace
JaegerTracingEnabled = false
ProbabilitySampler = 1.0
ServerName = "venus-messenger"
```

## Run

```sh
./venus-messager -config ./messager.toml
./venus-messager run --auth-url=http://127.0.0.1:8989 --node-url=/ip4/127.0.0.1/tcp/3453 --gateway-url=/ip4/127.0.0.1/tcp/45132 --auth-token=<auth-token>
```
19 changes: 6 additions & 13 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package config

import (
"github.com/ipfs-force-community/metrics"
"time"

"github.com/ipfs-force-community/metrics"

gatewayTypes "github.com/ipfs-force-community/venus-gateway/types"
)

Expand All @@ -15,7 +16,6 @@ type Config struct {
Node NodeConfig `toml:"node"`
MessageService MessageServiceConfig `toml:"messageService"`
MessageState MessageStateConfig `toml:"messageState"`
Wallet WalletConfig `toml:"wallet"`
Gateway GatewayConfig `toml:"gateway"`
RateLimit RateLimitConfig `toml:"rateLimit"`
Trace metrics.TraceConfig `toml:"tracing"`
Expand Down Expand Up @@ -62,10 +62,6 @@ type JWTConfig struct {
} `toml:"local"`
}

type WalletConfig struct {
ScanInterval int `toml:"scanInterval"` // second
}

type MessageServiceConfig struct {
TipsetFilePath string `toml:"tipsetFilePath"`
SkipProcessHead bool `toml:"skipProcessHead"`
Expand Down Expand Up @@ -113,12 +109,9 @@ func DefaultConfig() *Config {
Address: "/ip4/0.0.0.0/tcp/39812",
},
Node: NodeConfig{
Url: "",
Url: "/ip4/127.0.0.1/tcp/3453",
Token: "",
},
Wallet: WalletConfig{
ScanInterval: 10,
},
MessageState: MessageStateConfig{
BackTime: 3600 * 24,
DefaultExpiration: 3600 * 24 * 3,
Expand All @@ -130,17 +123,17 @@ func DefaultConfig() *Config {
SkipPushMessage: false,
},
Gateway: GatewayConfig{
RemoteEnable: false,
RemoteEnable: true,
Token: "",
Url: "",
Url: "/ip4/127.0.0.1/tcp/45132",
Cfg: gatewayTypes.Config{
RequestQueueSize: 30,
RequestTimeout: time.Minute * 5,
},
},
RateLimit: RateLimitConfig{Redis: ""},
Trace: metrics.TraceConfig{
JaegerEndpoint: "localhost:6831",
JaegerEndpoint: "",
ProbabilitySampler: 1.0,
JaegerTracingEnabled: false,
ServerName: "venus-messenger",
Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package main
import (
"encoding/hex"
"fmt"
"github.com/filecoin-project/venus-messager/metrics"
"net"
_ "net/http/pprof"
"os"
"path/filepath"

"github.com/filecoin-project/venus-messager/metrics"

ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr/net"

Expand Down Expand Up @@ -206,7 +207,7 @@ func runAction(ctx *cli.Context) error {
provider := fx.Options(
fx.Logger(fxLogger{log}),
// prover
fx.Supply(cfg, &cfg.DB, &cfg.API, &cfg.JWT, &cfg.Node, &cfg.Log, &cfg.MessageService, &cfg.MessageState, &cfg.Wallet, &cfg.Gateway, &cfg.RateLimit, &cfg.Trace),
fx.Supply(cfg, &cfg.DB, &cfg.API, &cfg.JWT, &cfg.Node, &cfg.Log, &cfg.MessageService, &cfg.MessageState, &cfg.Gateway, &cfg.RateLimit, &cfg.Trace),
fx.Supply(log),
fx.Supply(client),
fx.Supply(walletClient),
Expand Down
23 changes: 13 additions & 10 deletions messager.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
Address = "/ip4/0.0.0.0/tcp/39812"

[db]
type = "mysql"
type = "sqlite"

[db.mysql]
connMaxLifeTime = "1m0s"
connectionString = "root:Root1234@(127.0.0.1:3306)/messager?parseTime=true&loc=Local"
connectionString = ""
debug = false
maxIdleConn = 10
maxOpenConn = 10
Expand All @@ -17,16 +17,16 @@
file = "./message.db"

[gateway]
remoteEnable = false
token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoidGVzdG1pbmVyIiwicGVybSI6ImFkbWluIiwiZXh0IjoiIn0.oakIfSg1Iiv1T2F1BtH1bsb_1GeXWuirdPSjvE5wQLs"
url = "/ip4/8.130.165.167/tcp/45132"
remoteEnable = true
token = ""
url = "/ip4/127.0.0.1/tcp/45132"

[gateway.cfg]
RequestQueueSize = 30
RequestTimeout = "5m0s"

[jwt]
authURL = ""
authURL = "http://127.0.0.1:8989"

[jwt.local]
secret = ""
Expand All @@ -47,11 +47,14 @@
backTime = 86400

[node]
token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoidGVzdG1pbmVyIiwicGVybSI6ImFkbWluIiwiZXh0IjoiIn0.oakIfSg1Iiv1T2F1BtH1bsb_1GeXWuirdPSjvE5wQLs"
url = "/ip4/8.130.165.167/tcp/3453"
token = ""
url = "/ip4/127.0.0.1/tcp/3453"

[rateLimit]
redis = ""

[wallet]
scanInterval = 10
[tracing]
JaegerEndpoint = ""
JaegerTracingEnabled = false
ProbabilitySampler = 1.0
ServerName = "venus-messenger"