adapter_service

package
v0.0.0-...-d193908 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRegisteredJobSpecs

func GetRegisteredJobSpecs(w http.ResponseWriter, r *http.Request)

func InputDataExample

func InputDataExample(w http.ResponseWriter, r *http.Request)

InputDataExample reads the input JSON given from the core, calls the GetRestData method, and fulfills the request. It will log both the input and output JSON for troubleshooting.

func NewRouter

func NewRouter() *mux.Router

func PendingTaskRun

func PendingTaskRun(w http.ResponseWriter, r *http.Request)

GetPending method, and returns a RunResult with the pending status set to true. It will log both the input and output JSON for troubleshooting.

func ResumeFromPending

func ResumeFromPending(w http.ResponseWriter, r *http.Request)

ResumeFromPending allows you to resume a pending run, given its JobRunID.

func ReturnBigInt

func ReturnBigInt(w http.ResponseWriter, r *http.Request)

ReturnBigInt reads the input JSON given from the core, calls the GetBigInt method, and fulfills the request. It will log both the input and output JSON for troubleshooting.

func ReturnError

func ReturnError(w http.ResponseWriter, r *http.Request)

ReturnError returns an error back to the caller

func TaskRun

func TaskRun(w http.ResponseWriter, r *http.Request)

TaskRun reads the input JSON given from the core, calls the GetData method, and fulfills the request. It will log both the input and output JSON for troubleshooting.

func WriteData

func WriteData(w http.ResponseWriter, result RunResult)

WriteData returns the data to the requester

Types

type Chainlink struct {
	ID   string `json:"id"`
	Data Data   `json:"data"`
}

Chainlink contains the fields necessary for receiving the data that will be sent to the adapter and for returing back to the node itself.

func RequestData

func RequestData(w http.ResponseWriter, r *http.Request) Chainlink

RequestData makes the call to the external resources (in this case, that's simulated in chainlink.go).

type Data

type Data struct {
	Value   string  `json:"value,omitempty"`
	Details Details `json:"details,omitempty"`
	Other   string  `json:"other,omitempty"`
}

Data should be modeled after the target endpoint. You can use something like JSON-to-Go to make this easy: https://mholt.github.io/json-to-go/

type Details

type Details struct {
	Close   string  `json:"close,omitempty"`
	Open    float64 `json:"open,omitempty"`
	Current string  `json:"current,omitempty"`
}

Details is just a simple nested JSON object.

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

type Routes

type Routes []Route

type RunResult

type RunResult struct {
	JobRunID     string      `json:"jobRunId"`
	Data         Data        `json:"data"`
	Status       string      `json:"status"`
	ErrorMessage null.String `json:"error"`
	Pending      bool        `json:"pending"`
}

RunResult formats the response data to the format that the node expects.

func GetBigInt

func GetBigInt(cl Chainlink) RunResult

GetBigInt returns the max value of a uInt256 type in Solidity.

func GetData

func GetData(cl Chainlink) RunResult

GetData is where you woud reach out to your desired endpoint and store the response in the Data struct.

func GetError

func GetError(cl Chainlink) RunResult

GetError returns an error object to the caller

func GetInputData

func GetInputData(cl Chainlink) RunResult

GetInputData allows data to be passed into the adapter and the result will be determined based on what it is given. Pass in '{"other": "GetData"}' to retrieve the value "10000" Pass in '{"other": "GetBigInt"}' to retrieve the value "20000" Pass in '{"other": "GetRestData"}' to retrieve the value "30000"

func GetPending

func GetPending(cl Chainlink) RunResult

GetPending returns the pending field as true without data.

func GetReportData

func GetReportData(cl Chainlink) RunResult

GetReportData allows data to be passed into the adapter and the result will be determined based on what it is given.

Jump to

Keyboard shortcuts

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