Skip to content
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
38 changes: 0 additions & 38 deletions configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"os"
"strconv"
"strings"

"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -86,13 +85,6 @@ type ClickhouseConfig struct {
ChainBasedConfig map[string]TableOverrideConfig `mapstructure:"chainBasedConfig"`
EnableParallelViewProcessing bool `mapstructure:"enableParallelViewProcessing"`
MaxQueryTime int `mapstructure:"maxQueryTime"`

// Readonly configuration for API endpoints
ReadonlyHost string `mapstructure:"readonlyHost"`
ReadonlyPort int `mapstructure:"readonlyPort"`
ReadonlyUsername string `mapstructure:"readonlyUsername"`
ReadonlyPassword string `mapstructure:"readonlyPassword"`
ReadonlyDatabase string `mapstructure:"readonlyDatabase"`
}

type PostgresConfig struct {
Expand Down Expand Up @@ -290,35 +282,5 @@ func setCustomJSONConfigs() error {
Cfg.Storage.Main.Clickhouse.ChainBasedConfig = orchestratorChainConfig
}
}

// Load readonly ClickHouse configuration from environment variables
if readonlyHost := os.Getenv("CLICKHOUSE_HOST_READONLY"); readonlyHost != "" {
if Cfg.Storage.Main.Clickhouse != nil {
Cfg.Storage.Main.Clickhouse.ReadonlyHost = readonlyHost
}
}
if readonlyPort := os.Getenv("CLICKHOUSE_PORT_READONLY"); readonlyPort != "" {
if port, err := strconv.Atoi(readonlyPort); err == nil {
if Cfg.Storage.Main.Clickhouse != nil {
Cfg.Storage.Main.Clickhouse.ReadonlyPort = port
}
}
}
if readonlyUsername := os.Getenv("CLICKHOUSE_USER_READONLY"); readonlyUsername != "" {
if Cfg.Storage.Main.Clickhouse != nil {
Cfg.Storage.Main.Clickhouse.ReadonlyUsername = readonlyUsername
}
}
if readonlyPassword := os.Getenv("CLICKHOUSE_PASSWORD_READONLY"); readonlyPassword != "" {
if Cfg.Storage.Main.Clickhouse != nil {
Cfg.Storage.Main.Clickhouse.ReadonlyPassword = readonlyPassword
}
}
if readonlyDatabase := os.Getenv("CLICKHOUSE_DATABASE_READONLY"); readonlyDatabase != "" {
if Cfg.Storage.Main.Clickhouse != nil {
Cfg.Storage.Main.Clickhouse.ReadonlyDatabase = readonlyDatabase
}
}

return nil
}
42 changes: 0 additions & 42 deletions configs/config_readonly_example.yml

This file was deleted.

235 changes: 0 additions & 235 deletions docs/README_READONLY_CLICKHOUSE.md

This file was deleted.

Binary file modified insight
100644 → 100755
Binary file not shown.
20 changes: 20 additions & 0 deletions internal/handlers/logs_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package handlers

import (
"net/http"
"sync"

"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/gin-gonic/gin"
Expand All @@ -12,6 +13,13 @@ import (
"github.com/thirdweb-dev/indexer/internal/storage"
)

// package-level variables
var (
mainStorage storage.IMainStorage
storageOnce sync.Once
storageErr error
)

// @Summary Get all logs
// @Description Retrieve all logs across all contracts
// @Tags events
Expand Down Expand Up @@ -213,6 +221,18 @@ func decodeLogsIfNeeded(chainId string, logs []common.Log, eventABI *abi.Event,
return nil
}

func getMainStorage() (storage.IMainStorage, error) {
storageOnce.Do(func() {
var err error
mainStorage, err = storage.NewConnector[storage.IMainStorage](&config.Cfg.Storage.Main)
if err != nil {
storageErr = err
log.Error().Err(err).Msg("Error creating storage connector")
}
})
return mainStorage, storageErr
}

func sendJSONResponse(c *gin.Context, response interface{}) {
c.JSON(http.StatusOK, response)
}
Expand Down
Loading