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

Expose a Status Endpoint for check:* #143

Merged
merged 15 commits into from
Sep 30, 2020
Merged

Conversation

patrick-ogrady
Copy link
Contributor

@patrick-ogrady patrick-ogrady commented Sep 30, 2020

This PR introduces the ability to programatically access the status of check:data or check:construction tests. To try it out, you can run the following scripts:

check:data

package main

import (
	"log"

	"github.com/coinbase/rosetta-cli/pkg/results"
	"github.com/coinbase/rosetta-sdk-go/types"
)

func main() {
	status, err := results.FetchCheckDataStatus("http://localhost:9090")
	if err != nil {
		log.Fatalf("%s: unable to fetch data status", err.Error())
	}

	log.Printf("Status: %s\n", types.PrettyPrintStruct(status))
}

This logs:

 {
 "stats": {
  "blocks": 61769,
  "orphans": 0,
  "transactions": 113885,
  "operations": 366906,
  "active_reconciliations": 0,
  "inactive_reconciliations": 0,
  "reconciliation_coverage": 0
 },
 "progress": {
  "blocks": 61844,
  "tip": 1836794,
  "completed": 3.3669535070345398,
  "rate": 140.55454545454546,
  "time_remaining": "3h30m28s"
 }
}

check:construction

package main

import (
	"log"

	"github.com/coinbase/rosetta-cli/pkg/results"
	"github.com/coinbase/rosetta-sdk-go/types"
)

func main() {
	status, err := results.FetchCheckConstructionStatus("http://localhost:9090")
	if err != nil {
		log.Fatalf("%s: unable to fetch data status", err.Error())
	}

	log.Printf("Status: %s\n", types.PrettyPrintStruct(status))
}

This logs:

{
    "stats": {
        "transactions_confirmed": 1,
        "transactions_created": 3,
        "stale_broadcasts": 0,
        "failed_broadcasts": 0,
        "addresses_created": 5,
        "workflows_completed": {
            "create_account": 5,
            "request_funds": 1,
            "return_funds": 0,
            "transfer": 1
        }
    },
    "progress": {
        "broadcasting": 2,
        "processing": 2
    }
}

Changes

  • implement a server handler for both check:data and check:construction
  • migrate logger to use computations in pkg/tester
  • Add client for accessing status
  • update version

@coveralls
Copy link

coveralls commented Sep 30, 2020

Pull Request Test Coverage Report for Build 5012

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.5%) to 85.279%

Totals Coverage Status
Change from base Build 4912: 0.5%
Covered Lines: 168
Relevant Lines: 197

💛 - Coveralls

@patrick-ogrady patrick-ogrady merged commit a3b47a4 into master Sep 30, 2020
@patrick-ogrady patrick-ogrady deleted the patrick/progress-endpoint branch September 30, 2020 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants