-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from everFinance/dev/s3-store
Dev/s3 store
- Loading branch information
Showing
20 changed files
with
900 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/everFinance/goar/types" | ||
ts "github.com/everFinance/turing/example/schema" | ||
"github.com/everFinance/turing/rollup" | ||
"github.com/everFinance/turing/store/schema" | ||
"time" | ||
) | ||
|
||
func main() { | ||
tags := []types.Tag{ | ||
{Name: "App", Value: "turing-test"}, | ||
{Name: "Owner", Value: "k9sXK8x5lMxxM-PbDZ13tCeZi6rOtlll5a6_rrc2oGM"}, | ||
} | ||
suggestLastArTxId := "" | ||
arOwner := "k9sXK8x5lMxxM-PbDZ13tCeZi6rOtlll5a6_rrc2oGM" | ||
arNode := "https://arweave.net" | ||
arWalletKeyPath := "./k9s.json" | ||
rol := rollup.New(suggestLastArTxId, arNode, "", arWalletKeyPath, arOwner, tags, schema.Config{}) | ||
rol.Run(2*time.Minute, 999) | ||
feedData(rol.AddTx()) | ||
} | ||
|
||
func feedData(ch chan<- []byte) { | ||
ticker := time.NewTicker(30 * time.Second) | ||
var cnt int64 | ||
for { | ||
select { | ||
case <-ticker.C: | ||
tx := &ts.Tx{ | ||
Name: fmt.Sprintf("test-%v", cnt), | ||
Timestamp: time.Now().UnixMilli(), | ||
} | ||
data, err := json.Marshal(tx) | ||
if err != nil { | ||
panic(err) | ||
} | ||
cnt += 1 | ||
ch <- data | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/everFinance/goar/types" | ||
ts "github.com/everFinance/turing/example/schema" | ||
"github.com/everFinance/turing/rollup" | ||
"github.com/everFinance/turing/store/schema" | ||
"time" | ||
) | ||
|
||
func main() { | ||
tags := []types.Tag{ | ||
{Name: "App", Value: "turing-s3-test"}, | ||
{Name: "Owner", Value: "k9sXK8x5lMxxM-PbDZ13tCeZi6rOtlll5a6_rrc2oGM"}, | ||
} | ||
suggestLastArTxId := "" | ||
arOwner := "k9sXK8x5lMxxM-PbDZ13tCeZi6rOtlll5a6_rrc2oGM" | ||
arNode := "https://arweave.net" | ||
arWalletKeyPath := "./k9s.json" | ||
cfg := schema.Config{ | ||
UseS3: true, | ||
AccKey: "", | ||
SecretKey: "MOPfuebKVsSTZK7XGq/", | ||
BktPrefix: "turing", | ||
Region: "ap-northeast-1", | ||
} | ||
rol := rollup.New(suggestLastArTxId, arNode, "", arWalletKeyPath, arOwner, tags, cfg) | ||
rol.Run(2*time.Minute, 999) | ||
feedDataS3(rol.AddTx()) | ||
} | ||
|
||
func feedDataS3(ch chan<- []byte) { | ||
ticker := time.NewTicker(30 * time.Second) | ||
var cnt int64 | ||
for { | ||
select { | ||
case <-ticker.C: | ||
tx := &ts.Tx{ | ||
Name: fmt.Sprintf("test-S3-%v", cnt), | ||
Timestamp: time.Now().UnixMilli(), | ||
} | ||
data, err := json.Marshal(tx) | ||
if err != nil { | ||
panic(err) | ||
} | ||
cnt += 1 | ||
ch <- data | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package schema | ||
|
||
type Tx struct { | ||
Name string `json:"name"` | ||
Timestamp int64 `json:"timestamp"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/everFinance/goar/types" | ||
ts "github.com/everFinance/turing/example/schema" | ||
"github.com/everFinance/turing/store/schema" | ||
|
||
"github.com/everFinance/turing/tracker" | ||
) | ||
|
||
func main() { | ||
tags := []types.Tag{ | ||
{Name: "Owner", Value: "k9sXK8x5lMxxM-PbDZ13tCeZi6rOtlll5a6_rrc2oGM"}, | ||
} | ||
arOwner := "k9sXK8x5lMxxM-PbDZ13tCeZi6rOtlll5a6_rrc2oGM" | ||
arNode := "https://arweave.net" | ||
arseed := "" | ||
cursor := uint64(0) | ||
dbCfg := schema.Config{} | ||
tr := tracker.New(tags, arNode, arseed, arOwner, dbCfg) | ||
tr.Run(cursor) | ||
for { | ||
comTx := <-tr.SubscribeTx() | ||
tx := &ts.Tx{} | ||
err := json.Unmarshal(comTx.Data, tx) | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println(tx) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/everFinance/goar/types" | ||
"github.com/everFinance/turing/store/schema" | ||
"github.com/everFinance/turing/tracker" | ||
) | ||
|
||
func main() { | ||
tags := []types.Tag{ | ||
{Name: "Owner", Value: "uGx-QfBXSwABKxjha-00dI7vvfyqIYblY6Z5L6cyTFM"}, | ||
} | ||
arOwner := "uGx-QfBXSwABKxjha-00dI7vvfyqIYblY6Z5L6cyTFM" | ||
arNode := "https://arweave.net" | ||
arseed := "" | ||
cursor := uint64(40) | ||
dbCfg := schema.Config{ | ||
UseS3: true, | ||
AccKey: "", | ||
SecretKey: "MOPfueG+//", | ||
BktPrefix: "turing", | ||
Region: "ap-northeast-1", | ||
} | ||
tr := tracker.New(tags, arNode, arseed, arOwner, dbCfg) | ||
tr.Run(cursor) | ||
for { | ||
tx := <-tr.SubscribeTx() | ||
fmt.Println(tx.CursorId) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.