Version: v1.3.2 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2022 License: Apache-2.0, MIT Imports: 16 Imported by: 9



Package http provides a drand client implementation that uses drand's HTTP API.

The HTTP client uses drand's JSON HTTP API ( to fetch randomness. Watching is implemented by polling the endpoint at the expected round time.


package main

import (


var urls = []string{

var chainHash, _ = hex.DecodeString("8990e7a9aaed2ffed73dbd7092123d6f289930540d7651336225dc172e51b2ce")

func main() {
	c, err := client.New(
		client.From(http.ForURLs(urls, chainHash)...),

The "ForURLs" helper creates multiple HTTP clients from a list of URLs. Alternatively you can use the "New" or "NewWithInfo" constructor to create clients.

Tip: Provide multiple URLs to enable failover and speed optimized URL selection.



View Source
const HTTPHeartbeatInterval = 10 * time.Second

HTTPHeartbeatInterval is the duration between liveness heartbeats sent to an HTTP API.


This section is empty.


func ForURLs

func ForURLs(urls []string, chainHash []byte) []client.Client

ForURLs provides a shortcut for creating a set of HTTP clients for a set of URLs.

func New

func New(url string, chainHash []byte, transport nhttp.RoundTripper) (client.Client, error)

New creates a new client pointing to an HTTP endpoint

func NewWithInfo

func NewWithInfo(url string, info *chain.Info, transport nhttp.RoundTripper) (client.Client, error)

NewWithInfo constructs an http client when the group parameters are already known.


type HealthMetrics

type HealthMetrics struct {
	// contains filtered or unexported fields

HealthMetrics is a measurement task around HTTP clients

func MeasureHeartbeats

func MeasureHeartbeats(ctx context.Context, c []client.Client) *HealthMetrics

MeasureHeartbeats periodically tracks latency observed on a set of HTTP clients

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL