Documentation ¶
Index ¶
- Constants
- func AuthenticateBridgeType(bt *BridgeType, token string) (bool, error)
- func AuthenticateExternalInitiator(eia *auth.Token, ea *ExternalInitiator) (bool, error)
- func MarshalBridgeMetaData(latestAnswer *big.Int, updatedAt *big.Int) (map[string]interface{}, error)
- func NewBridgeType(btr *BridgeTypeRequest) (*BridgeTypeAuthentication, *BridgeType, error)
- type BridgeMetaData
- type BridgeMetaDataJSON
- type BridgeName
- type BridgeResponse
- type BridgeType
- type BridgeTypeAuthentication
- type BridgeTypeRequest
- type Cache
- func (c *Cache) BridgeTypes(ctx context.Context, offset int, limit int) ([]BridgeType, int, error)
- func (c *Cache) Close() error
- func (c *Cache) CreateBridgeType(ctx context.Context, bt *BridgeType) error
- func (c *Cache) DeleteBridgeType(ctx context.Context, bt *BridgeType) error
- func (c *Cache) FindBridge(ctx context.Context, name BridgeName) (BridgeType, error)
- func (c *Cache) FindBridges(ctx context.Context, names []BridgeName) ([]BridgeType, error)
- func (c *Cache) GetCachedResponse(ctx context.Context, dotId string, specId int32, maxElapsed time.Duration) ([]byte, error)
- func (c *Cache) HealthReport() map[string]error
- func (c *Cache) Name() string
- func (c *Cache) Start(_ context.Context) error
- func (c *Cache) UpdateBridgeType(ctx context.Context, bt *BridgeType, btr *BridgeTypeRequest) error
- func (c *Cache) UpsertBridgeResponse(ctx context.Context, dotId string, specId int32, response []byte) error
- func (c *Cache) WithDataSource(ds sqlutil.DataSource) ORM
- type ExternalInitiator
- type ExternalInitiatorRequest
- type ORM
Constants ¶
const ( CacheServiceName = "BridgeCache" DefaultUpsertInterval = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func AuthenticateBridgeType ¶
func AuthenticateBridgeType(bt *BridgeType, token string) (bool, error)
AuthenticateBridgeType returns true if the passed token matches its IncomingToken, or returns false with an error.
func AuthenticateExternalInitiator ¶
func AuthenticateExternalInitiator(eia *auth.Token, ea *ExternalInitiator) (bool, error)
AuthenticateExternalInitiator compares an auth against an initiator and returns true if the password hashes match
func MarshalBridgeMetaData ¶
func NewBridgeType ¶
func NewBridgeType(btr *BridgeTypeRequest) (*BridgeTypeAuthentication, *BridgeType, error)
NewBridgeType returns a bridge type authentication (with plaintext password) and a bridge type (with hashed password, for persisting)
Types ¶
type BridgeMetaData ¶
type BridgeMetaData struct { LatestAnswer *big.Int `json:"latestAnswer"` UpdatedAt *big.Int `json:"updatedAt"` // A unix timestamp }
NOTE: latestAnswer and updatedAt is the only metadata used. Currently market closer adapter and outlier detection depend latestAnswer. https://github.com/smartcontractkit/external-adapters-js/tree/f474bd2e2de13ebe5c9dc3df36ebb7018817005e/composite/market-closure https://github.com/smartcontractkit/external-adapters-js/tree/5abb8e5ec2024f724fd39122897baa63c3cd0167/composite/outlier-detection
type BridgeMetaDataJSON ¶
type BridgeMetaDataJSON struct {
Meta BridgeMetaData
}
type BridgeName ¶
type BridgeName string
BridgeName defines what Adapter a TaskSpec will use.
func MustParseBridgeName ¶
func MustParseBridgeName(val string) BridgeName
MustParseBridgeName instantiates a new BridgeName, and panics if a bad input is provided.
func ParseBridgeName ¶
func ParseBridgeName(val string) (BridgeName, error)
ParseBridgeName returns a formatted Task type.
func (BridgeName) MarshalJSON ¶
func (t BridgeName) MarshalJSON() ([]byte, error)
MarshalJSON converts a BridgeName to a JSON byte slice.
func (*BridgeName) Scan ¶
func (t *BridgeName) Scan(value interface{}) error
Scan reads the database value and returns an instance.
func (BridgeName) String ¶
func (t BridgeName) String() string
String returns this BridgeName as a string.
func (*BridgeName) UnmarshalJSON ¶
func (t *BridgeName) UnmarshalJSON(input []byte) error
UnmarshalJSON converts a bytes slice of JSON to a BridgeName.
type BridgeResponse ¶ added in v2.14.0
type BridgeType ¶
type BridgeType struct { Name BridgeName URL models.WebURL Confirmations uint32 IncomingTokenHash string Salt string OutgoingToken string MinimumContractPayment *assets.Link CreatedAt time.Time UpdatedAt time.Time }
BridgeType is used for external adapters and has fields for the name of the adapter and its URL.
type BridgeTypeAuthentication ¶
type BridgeTypeAuthentication struct { Name BridgeName URL models.WebURL Confirmations uint32 IncomingToken string OutgoingToken string MinimumContractPayment *assets.Link }
BridgeTypeAuthentication is the record returned in response to a request to create a BridgeType
type BridgeTypeRequest ¶
type BridgeTypeRequest struct { Name BridgeName `json:"name"` URL models.WebURL `json:"url"` Confirmations uint32 `json:"confirmations"` MinimumContractPayment *assets.Link `json:"minimumContractPayment"` }
BridgeTypeRequest is the incoming record used to create a BridgeType
func (BridgeTypeRequest) GetID ¶
func (bt BridgeTypeRequest) GetID() string
GetID returns the ID of this structure for jsonapi serialization.
func (BridgeTypeRequest) GetName ¶
func (bt BridgeTypeRequest) GetName() string
GetName returns the pluralized "type" of this structure for jsonapi serialization.
func (*BridgeTypeRequest) SetID ¶
func (bt *BridgeTypeRequest) SetID(value string) error
SetID is used to set the ID of this structure when deserializing from jsonapi documents.
type Cache ¶ added in v2.14.0
type Cache struct { // dependencies and configurations ORM // service state services.StateMachine // contains filtered or unexported fields }
func (*Cache) BridgeTypes ¶ added in v2.14.0
func (*Cache) CreateBridgeType ¶ added in v2.14.0
func (c *Cache) CreateBridgeType(ctx context.Context, bt *BridgeType) error
func (*Cache) DeleteBridgeType ¶ added in v2.14.0
func (c *Cache) DeleteBridgeType(ctx context.Context, bt *BridgeType) error
func (*Cache) FindBridge ¶ added in v2.14.0
func (c *Cache) FindBridge(ctx context.Context, name BridgeName) (BridgeType, error)
func (*Cache) FindBridges ¶ added in v2.14.0
func (c *Cache) FindBridges(ctx context.Context, names []BridgeName) ([]BridgeType, error)
func (*Cache) GetCachedResponse ¶ added in v2.14.0
func (*Cache) HealthReport ¶ added in v2.14.0
func (*Cache) UpdateBridgeType ¶ added in v2.14.0
func (c *Cache) UpdateBridgeType(ctx context.Context, bt *BridgeType, btr *BridgeTypeRequest) error
func (*Cache) UpsertBridgeResponse ¶ added in v2.14.0
func (*Cache) WithDataSource ¶ added in v2.14.0
func (c *Cache) WithDataSource(ds sqlutil.DataSource) ORM
type ExternalInitiator ¶
type ExternalInitiator struct { ID int64 Name string URL *models.WebURL AccessKey string Salt string HashedSecret string OutgoingSecret string OutgoingToken string CreatedAt time.Time UpdatedAt time.Time }
ExternalInitiator represents a user that can initiate runs remotely
func NewExternalInitiator ¶
func NewExternalInitiator( eia *auth.Token, eir *ExternalInitiatorRequest, ) (*ExternalInitiator, error)
NewExternalInitiator generates an ExternalInitiator from an auth.Token, hashing the password for storage
type ExternalInitiatorRequest ¶
type ExternalInitiatorRequest struct { Name string `json:"name"` URL *models.WebURL `json:"url,omitempty"` }
ExternalInitiatorRequest is the incoming record used to create an ExternalInitiator.
type ORM ¶
type ORM interface { FindBridge(ctx context.Context, name BridgeName) (bt BridgeType, err error) FindBridges(ctx context.Context, name []BridgeName) (bts []BridgeType, err error) DeleteBridgeType(ctx context.Context, bt *BridgeType) error BridgeTypes(ctx context.Context, offset int, limit int) ([]BridgeType, int, error) CreateBridgeType(ctx context.Context, bt *BridgeType) error UpdateBridgeType(ctx context.Context, bt *BridgeType, btr *BridgeTypeRequest) error GetCachedResponse(ctx context.Context, dotId string, specId int32, maxElapsed time.Duration) ([]byte, error) UpsertBridgeResponse(ctx context.Context, dotId string, specId int32, response []byte) error ExternalInitiators(ctx context.Context, offset int, limit int) ([]ExternalInitiator, int, error) CreateExternalInitiator(ctx context.Context, externalInitiator *ExternalInitiator) error DeleteExternalInitiator(ctx context.Context, name string) error FindExternalInitiator(ctx context.Context, eia *auth.Token) (*ExternalInitiator, error) FindExternalInitiatorByName(ctx context.Context, iname string) (exi ExternalInitiator, err error) GetCachedResponseWithFinished(ctx context.Context, dotId string, specId int32, maxElapsed time.Duration) ([]byte, time.Time, error) BulkUpsertBridgeResponse(ctx context.Context, responses []BridgeResponse) error WithDataSource(sqlutil.DataSource) ORM }
func NewORM ¶
func NewORM(ds sqlutil.DataSource) ORM