Skip to content

Conversation

@denis-chernov-smartcontract
Copy link

@denis-chernov-smartcontract denis-chernov-smartcontract commented Dec 16, 2025

Closes DS-1421, DS-1423

Description

Implements the following functionality:

  • One metrics endpoint: http_requests_total
  • Metrics middleware
  • Redcon service that implements Redis mock service
  • API server
  • Main file

@changeset-bot
Copy link

changeset-bot bot commented Dec 16, 2025

⚠️ No Changeset found

Latest commit: 2908e7b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment on lines +21 to +22
maxWaitTime := 60 * time.Second
checkInterval := 500 * time.Millisecond
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: These sounds like good candidates for config values.

This is true for most numbers that appear in the PR - web server configs and so on. This doesn't mean we NEED them in a conf or that moving them to a conf needs to happen in this PR.

Comment on lines 293 to 296
// Remove from tracker after subscription attempt completes
// Allow retries after 10 seconds if data still not available
time.Sleep(10 * time.Second)
s.subscriptionTracker.Delete(key)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder about this part. Could we fire off a goroutine which checks the cache for the subscription key every 100ms and times out after some time (3s, 5s, etc.)? I might be overthinking it, though.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot imagine any cleaner way to do it, tbh. But I'm open to any suggestions.

Comment on lines 302 to 310
// Get error response from pool
errorResp := errorResponsePool.Get().(*ErrorResponseData)
defer errorResponsePool.Put(errorResp)

errorResp.Error.Name = "AdapterError"
errorResp.Error.Message = "The EA has not received any values from the Data Provider for the requested data yet. Retry after a short delay, and if the problem persists raise this issue in the relevant channels."

c.JSON(http.StatusGatewayTimeout, errorResp)
return
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of code is supposed to execute when the attempt to subscribe times out. The way the code is right now, it will fire off every time.

If we want this call to be blocking then we'll need some channel or wait group to sync the execution of the sub goroutine (line 291) and either return the requested value from the cache or return a timeout error.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of code is supposed to execute when the attempt to subscribe times out.
I don't think so. subscribeToAsset is called in a goroutine, so it's not blocking.
The idea here is that we return 504 with "The EA has not received any values..." regardless of the subscription status. Nothing in the cache - return 504.

Copy link

@ro-tex ro-tex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@denis-chernov-smartcontract denis-chernov-smartcontract merged commit 4ba846e into streams-adapters Jan 2, 2026
@denis-chernov-smartcontract denis-chernov-smartcontract deleted the DS-1423/api-service branch January 2, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants