mercury

package
v2.9.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	FeedIDs     = "feedIDs"     // valid for v0.3
	FeedIdHex   = "feedIdHex"   // valid for v0.2
	BlockNumber = "blockNumber" // valid for v0.2
	Timestamp   = "timestamp"   // valid for v0.3

)

Variables

View Source
var CalculateRetryConfigFn = func(prk string, mercuryConfig MercuryConfigProvider) time.Duration {
	var retryInterval time.Duration
	var retries int
	totalAttempts, ok := mercuryConfig.GetPluginRetry(prk)
	if ok {
		retries = totalAttempts.(int)
		if retries < totalFastPluginRetries {
			retryInterval = 1 * time.Second
		} else if retries < totalMediumPluginRetries {
			retryInterval = 5 * time.Second
		}

	} else {
		retryInterval = 1 * time.Second
	}
	mercuryConfig.SetPluginRetry(prk, retries+1, cache.DefaultExpiration)
	return retryInterval
}

CalculateRetryConfig returns plugin retry interval based on how many times plugin has retried this work

View Source
var GenerateHMACFn = func(method string, path string, body []byte, clientId string, secret string, ts int64) string {
	bodyHash := sha256.New()
	bodyHash.Write(body)
	hashString := fmt.Sprintf("%s %s %s %s %d",
		method,
		path,
		hex.EncodeToString(bodyHash.Sum(nil)),
		clientId,
		ts)
	signedMessage := hmac.New(sha256.New, []byte(secret))
	signedMessage.Write([]byte(hashString))
	userHmac := hex.EncodeToString(signedMessage.Sum(nil))
	return userHmac
}

Functions

func NewAbiPacker added in v2.9.0

func NewAbiPacker() *abiPacker

Types

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type MercuryClient

type MercuryClient interface {
	DoRequest(ctx context.Context, streamsLookup *StreamsLookup, pluginRetryKey string) (encoding.PipelineExecutionState, encoding.UpkeepFailureReason, [][]byte, bool, time.Duration, error)
}

type MercuryConfigProvider

type MercuryConfigProvider interface {
	Credentials() *types.MercuryCredentials
	IsUpkeepAllowed(string) (interface{}, bool)
	SetUpkeepAllowed(string, interface{}, time.Duration)
	GetPluginRetry(string) (interface{}, bool)
	SetPluginRetry(string, interface{}, time.Duration)
}

type MercuryData

type MercuryData struct {
	Index     int
	Error     error
	Retryable bool
	Bytes     [][]byte
	State     encoding.PipelineExecutionState
}

type Packer

type Packer interface {
	UnpackCheckCallbackResult(callbackResp []byte) (encoding.PipelineExecutionState, bool, []byte, encoding.UpkeepFailureReason, *big.Int, error)
	PackGetUpkeepPrivilegeConfig(upkeepId *big.Int) ([]byte, error)
	UnpackGetUpkeepPrivilegeConfig(resp []byte) ([]byte, error)
	DecodeStreamsLookupRequest(data []byte) (*StreamsLookupError, error)
}

type StreamsLookup

type StreamsLookup struct {
	*StreamsLookupError
	UpkeepId *big.Int
	Block    uint64
}

func (*StreamsLookup) IsMercuryV02

func (l *StreamsLookup) IsMercuryV02() bool

func (*StreamsLookup) IsMercuryV03

func (l *StreamsLookup) IsMercuryV03() bool

func (*StreamsLookup) IsMercuryV03UsingBlockNumber added in v2.9.0

func (l *StreamsLookup) IsMercuryV03UsingBlockNumber() bool

IsMercuryV03UsingBlockNumber is used to distinguish the batch path. It is used for Mercury V03 only

type StreamsLookupError

type StreamsLookupError struct {
	FeedParamKey string
	Feeds        []string
	TimeParamKey string
	Time         *big.Int
	ExtraData    []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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