Skip to content

Commit

Permalink
chore: remove unused config
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudoyu committed Nov 17, 2023
1 parent 71d8bda commit c494589
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 234 deletions.
106 changes: 9 additions & 97 deletions deploy/config.development.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
discovery:
version: "1.0.0" # version of your RSS3 node
version: "1.0.0"
maintainer:
owner_evm_address: "0x123" # address to receive network incentivization and ownership verification
signature: "hello_world" # signature of the above address
website: "https://abc.com/rss3-node" # link to your website
# public_endpoint is how the Global Indexer reaches your RSS3 node
# a domain name is recommended but not required, you can use an IP address+port as well
owner_evm_address: "0x123"
signature: "hello_world"
website: "https://abc.com/rss3-node"
node:
endpoint: "https://rss3.abc.com/"
access_key: "access_key"
Expand All @@ -18,108 +16,22 @@ config:
network: arweave
chain: mainnet
endpoint: https://ethereum.blockpi.network/v1/rpc/public
# the following config is for your RSS3 node to operate on data
data:
database:
type: "CockroachDB"
external: true # if set to true, the automated deployment process will not sprint up a database container.
host: "pg.abc.com"
external: true
host: "127.0.0.1"
port: 5432
username: "username"
password: "password"
database_name: "abc"

redis:
external: true
host: "redis.abc.com"
port: 6379
password: "password"
database_name: 1 # redis database index

object_storage:
external: true
type: "s3"
endpoint:
private:
public:
bucket:
credential:
id:
secret:
# the following config is for your RSS3 node to spring up components
database_name: "db"
component:
data:
indexer_module: # leave it empty to disable individual module here
decentralized:
network: # list all the supported networks here, see: https://docs.rss3.io/docs/supported-networks
indexer:
# fallback is a special indexer that stores all on-chain transctions
# that are not handled by other indexersinto database.
# when enabled, a CockroachDB is required.
- type: fallback
args:
- chain_id: "0x01,0x137" # 或者用下面的格式

- type: app_uniswap
args:
- chain_id: ["0x01","0x137"]

- type: app_snapshot
args:
- api_key: "12345678"
- upstream_endpoint: "https://snapshot.app/graphql"

- type: app_mirror
args:
- upstream_endpoint: "https://arweave-gateway.abc.com/"
depends_on:
storage:
- "arweave_storage_1"

- type: app_farcaster
args:
- upstream_endpoint: "https://farcaster-hub.abc.com/"

storage: # storage used by applications, indexers may require read-only access to retrieve data
- id: "ipfs_storage_1"
upstream_endpoint: "https://ipfs-gateway.abc.com/" # your IPFS gateway endpoint

- id: "arweave_storage_1"
upstream_endpoint: "https://arweave-gateway.abc.com/" # your Arweave gateway endpoint

indexer_module:
RSS:
# RSSHub is the only supported RSS module for now
# as RSSHub is an external dependency, you need to make sure:
# 1. the instance must be accessible by your RSS3 node itself
# 2. certain APIs must be accessible by the Global Indexer:
# 2.1 /api/routes # TBD
# 2.2 /api/config # TBD
RSSHub:
# instance_url stands for the RSSHub instance you are running
instance_url: "https://rsshub.abc.com/"
# proper authentication is highly recommended to protect your RSSHub instance
# choose an authentication method: basic auth using username/password
# or query string auth using access_key
# make sure it's always accessible by your RSS3 node
# see: https://docs.rsshub.app/install/#user-authentication-configurations
instance_url: "https://rsshub.app/"
authentication:
username: "username"
password: "password"
access_key: "access_key"

federated: # leave blank for now

search: # leave blank for now

observability:
opentelemetry:
# leave blank to disable individual signal here
# see: https://opentelemetry.io/
metrics:
endpoint: "https://opentelemetry.abc.com/metrics"

logs:
endpoint: "https://opentelemetry.abc.com/logs"

traces:
endpoint: "https://opentelemetry.abc.com/traces"
105 changes: 4 additions & 101 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ const (

// Config represents the top-level configuration structure.
type File struct {
Discovery Discovery `mapstructure:"discovery"`
Config Config `mapstructure:"config"`
Observability Observability `mapstructure:"observability"`
Discovery Discovery `mapstructure:"discovery"`
Config Config `mapstructure:"config"`
}

// Discovery represents the discovery configuration.
Expand Down Expand Up @@ -56,9 +55,7 @@ type HubConfig struct {

// DataConfig holds data related configuration.
type DataConfig struct {
Database DatabaseConfig `mapstructure:"database"`
Redis RedisConfig `mapstructure:"redis"`
ObjectStorage ObjectStorageConfig `mapstructure:"object_storage"`
Database DatabaseConfig `mapstructure:"database"`
}

// DatabaseConfig holds database configuration.
Expand All @@ -72,128 +69,34 @@ type DatabaseConfig struct {
DatabaseName string `mapstructure:"database_name"`
}

// RedisConfig holds Redis configuration.
type RedisConfig struct {
External bool `mapstructure:"external"`
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
Password string `mapstructure:"password"`
DatabaseName int `mapstructure:"database_name"`
}

// ObjectStorageConfig holds object storage configuration.
type ObjectStorageConfig struct {
External bool `mapstructure:"external"`
Type string `mapstructure:"type"`
Endpoint EndpointConfig `mapstructure:"endpoint"`
Bucket string `mapstructure:"bucket"`
Credential CredentialConfig `mapstructure:"credential"`
}

// EndpointConfig holds endpoints for object storage.
type EndpointConfig struct {
Private string `mapstructure:"private"`
Public string `mapstructure:"public"`
}

// CredentialConfig holds credentials for object storage.
type CredentialConfig struct {
ID string `mapstructure:"id"`
Secret string `mapstructure:"secret"`
}

// ComponentConfig holds component configuration.
type ComponentConfig struct {
Data DataComponentConfig `mapstructure:"data"`
Search interface{} `mapstructure:"search"`
}

// DataComponentConfig holds data component configuration.
type DataComponentConfig struct {
IndexerModule IndexerModuleConfig `mapstructure:"indexer_module"`
}

// IndexerModuleConfig holds indexer module configuration.
type IndexerModuleConfig struct {
Decentralized DecentralizedConfig `mapstructure:"decentralized"`
RSS RSSConfig `mapstructure:"RSS"`
Federated interface{} `mapstructure:"federated"`
}

// DecentralizedConfig holds decentralized configuration.
type DecentralizedConfig struct {
Network NetworkConfig `mapstructure:"network"`
Storage []StorageConfig `mapstructure:"storage"`
}

// NetworkConfig holds network specific configuration.
type NetworkConfig struct {
Indexer []IndexerConfig `mapstructure:"indexer"`
}

// IndexerConfig holds indexer specific configuration.
type IndexerConfig struct {
Type string `mapstructure:"type"`
Args []map[string]interface{} `mapstructure:"args"`
DependsOn DependsOnConfig `mapstructure:"depends_on"`
RSS RSSConfig `mapstructure:"RSS"`
}

// DependsOnConfig holds dependency information.
type DependsOnConfig struct {
Storage []string `mapstructure:"storage"`
}

// StorageConfig holds storage configuration.
type StorageConfig struct {
ID string `mapstructure:"id"`
UpstreamEndpoint string `mapstructure:"upstream_endpoint"`
}

// RSSConfig holds RSS module configuration.
type RSSConfig struct {
RSSHub RSSHubConfig `mapstructure:"RSSHub"`
}

// RSSHubConfig holds RSSHub specific configuration.
type RSSHubConfig struct {
InstanceURL string `mapstructure:"instance_url"`
Authentication AuthenticationConfig `mapstructure:"authentication"`
}

// AuthenticationConfig holds authentication configuration.
type AuthenticationConfig struct {
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
AccessKey string `mapstructure:"access_key"`
}

// Observability holds observability related configuration.
type Observability struct {
Opentelemetry OpentelemetryConfig `mapstructure:"opentelemetry"`
}

// OpentelemetryConfig holds OpenTelemetry configuration.
type OpentelemetryConfig struct {
Metrics MetricsConfig `mapstructure:"metrics"`
Logs LogsConfig `mapstructure:"logs"`
Traces TracesConfig `mapstructure:"traces"`
}

// MetricsConfig holds metrics configuration.
type MetricsConfig struct {
Endpoint string `mapstructure:"endpoint"`
}

// LogsConfig holds logs configuration.
type LogsConfig struct {
Endpoint string `mapstructure:"endpoint"`
}

// TracesConfig holds traces configuration.
type TracesConfig struct {
Endpoint string `mapstructure:"endpoint"`
}

func Setup(configFilePath string) (*File, error) {
viper.SetConfigFile(configFilePath)

Expand Down
33 changes: 1 addition & 32 deletions internal/node/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"net/http"
"strings"

"github.com/naturalselectionlabs/rss3-node/internal/config"
"github.com/naturalselectionlabs/rss3-node/internal/constant"
Expand Down Expand Up @@ -137,33 +136,6 @@ func (s *Server) registerNode(c config.File) error {
AccessKey: c.Discovery.Node.AccessKey,
}

//nolint:prealloc
var decentralized []schema.Decentralized

for _, indexerConfig := range c.Config.Component.Data.IndexerModule.Decentralized.Network.Indexer {
var networks []string

for _, arg := range indexerConfig.Args {
if chainID, ok := arg["chain_id"]; ok {
switch v := chainID.(type) {
case string:
networks = append(networks, strings.Split(v, ",")...)
case []interface{}:
for _, id := range v {
if idStr, ok := id.(string); ok {
networks = append(networks, idStr)
}
}
}
}
}

decentralized = append(decentralized, schema.Decentralized{
Type: indexerConfig.Type,
Network: networks,
})
}

var rss schema.RSS

if c.Config.Component.Data.IndexerModule.RSS.RSSHub.InstanceURL != "" {
Expand All @@ -175,15 +147,12 @@ func (s *Server) registerNode(c config.File) error {
}

indexerModule := schema.IndexerModule{
Decentralized: decentralized,
RSS: rss,
Federated: struct{}{},
RSS: rss,
}

component := schema.Component{
Data: schema.Data{
IndexerModule: indexerModule,
Search: struct{}{},
},
}

Expand Down
5 changes: 1 addition & 4 deletions schema/node_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ type RSSHub struct {
}

type IndexerModule struct {
Decentralized []Decentralized `json:"decentralized"`
RSS RSS `json:"rss"`
Federated struct{} `json:"federated"`
RSS RSS `json:"rss"`
}

type RSS struct {
Expand All @@ -36,7 +34,6 @@ type Component struct {

type Data struct {
IndexerModule IndexerModule `json:"indexer_module"`
Search struct{} `json:"search"`
}

type RegistrationData struct {
Expand Down

0 comments on commit c494589

Please sign in to comment.