Skip to content

STX5/oracle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

一、预言机架构图

二、常用命令

  • LIST ALL KEYS: etcdctl --endpoints=localhost:2379 get --prefix --keys-only ''
  • PUT JOB: etcdctl --endpoints=localhost:2379 put 011 '{"url":"http://www.baidu.com","pattern":" 1"}'

三、Quick Start

1. run a ETCD cluster

# your etcd executable directory
./etcd

2. run jobDeamon

cd cmd/jobDeamon
go run .

3. run worker

cd cmd/worker
go run .

4. put a job

# your etcd executable directory
./etcdctl  --endpoints=localhost:2379 put 011 '{"url":"http://www.baidu.com","pattern":" 1"}'

./etcdctl  --endpoints=localhost:2379 get --prefix --keys-only ''

This project is bulit for fault tolerance. You can have multiple wokers and jobDeamons running, and feel free to shut them down at any time(eg. shut a worker down when its working; shut a jobDeamon down when it detects a lock release event).

As long as there are at least one woker and one jobDeamon, every job will be done exactly once.

5.update worker config

POST请求

curl --location --request POST 'http://ip:port/update' \
--header 'Content-Type: application/json' \
--data-raw '<body data here>'

请求参数

名称 位置 类型 必选
body body object
» prefix body string
» endpoint body [string]

返回结果

  • 请求成功
状态码 状态码含义 说明
200 StatusOK 成功
  • 请求失败
状态码 状态码含义 说明
400 StatusBadRequest 请求结构体解析失败
405 StatusMethodNotAllowed 请求方法不支持

6. update job config

POST请求

curl --location --request POST 'http://ip:port/update' \
--header 'Content-Type: application/json' \
--data-raw '<body data here>'

请求参数

名称 位置 类型 必选
body body object
» endpoint body [string]

返回结果

  • 请求成功
状态码 状态码含义 说明
200 StatusOK 成功
  • 请求失败
状态码 状态码含义 说明
400 StatusBadRequest 请求结构体解析失败
405 StatusMethodNotAllowed 请求方法不支持

四. TODOs

  • 完善job的执行逻辑,使用pattern作为css selector/xPath来获得网页特定内容
  • 为job添加超时机制
  • ID为160位的二进制数,需要使用16进制表示以节约空间
  • 为worker的ID与prefix添加校验
  • 为worker添加一个http server,来接受配置变更:prefix变更以及etcd endpoint变更
  • 为jobDeamon添加一个http server,来接受配置变更:etcd endpoint变更
  • 给出能连上实验室实验节点的ETH Client。尝试部署一个智能合约,然后监听到智能合约的event
  • 尝试跑一下现有的预言机demo

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages