v1.5.8 Latest Latest

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

Go to latest
Published: Oct 19, 2023 License: Apache-2.0, MIT Imports: 17 Imported by: 17



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 IsServerReady added in v1.4.6

func IsServerReady(addr string) (er error)

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.

func Ping added in v1.4.6

func Ping(ctx context.Context, root string) error


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