Skip to content

Commit

Permalink
Make cache config optional, debug logs in cache, fix dispatcher url path
Browse files Browse the repository at this point in the history
  • Loading branch information
dkeysil committed Mar 8, 2024
1 parent 6bb46a0 commit 119d4a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type JsonRpcProxyConfig struct {
}

type JsonRpcCacheConfig struct {
DispatcherURL string `yaml:"dispatcherUrl" json:"dispatcherUrl" validate:"url"`
DispatcherURL string `yaml:"dispatcherUrl" json:"dispatcherUrl" validate:"omitempty,url"`
CacheExpirePeriodSeconds int `yaml:"cacheExpirePeriodSeconds" json:"cacheExpirePeriodSeconds" default:"300"`
}

Expand Down
6 changes: 4 additions & 2 deletions services/json-rpc/json_rpc_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ type PresignedURLItem struct {
func (c *JsonRpcCache) pollEvents() {
dispatcherClient := http.DefaultClient
dispatcherClient.Timeout = 10 * time.Second

dispatcherURL, _ := url.Parse(c.cfg.DispatcherURL)
dispatcherPath := dispatcherURL.Path

r2Client := http.DefaultClient

Expand All @@ -143,14 +145,14 @@ func (c *JsonRpcCache) pollEvents() {
log.Info("Polling for combined block events")

bucket := time.Now().Truncate(time.Second * 10).Unix()
dispatcherURL.Path, err = url.JoinPath(dispatcherURL.Path, fmt.Sprintf("%d", bucket))
dispatcherURL.Path, err = url.JoinPath(dispatcherPath, fmt.Sprintf("%d", bucket))
if err != nil {
continue
}

resp, err := dispatcherClient.Get(dispatcherURL.String())
if err != nil {
log.WithError(err).Error("Failed to get R2 url from dispatcher")
log.WithError(err).Debug("Failed to get R2 url from dispatcher")
continue
}

Expand Down

0 comments on commit 119d4a2

Please sign in to comment.