Skip to content

Commit

Permalink
caching in a separate file, skip TOML writing when using cache
Browse files Browse the repository at this point in the history
  • Loading branch information
skudasov committed Oct 18, 2024
1 parent aa79d5c commit 68f7476
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion framework/components/blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Node struct {
}

func NewBlockchainNetwork(input *Input) (*Output, error) {
if input.Out != nil && framework.NoCache() {
if input.Out != nil && framework.UseCache() {
return input.Out, nil
}
var out *Output
Expand Down
2 changes: 1 addition & 1 deletion framework/components/clnode/clnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type NodeOut struct {
}

func NewNode(in *Input) (*Output, error) {
if in.Out != nil && framework.NoCache() {
if in.Out != nil && framework.UseCache() {
return in.Out, nil
}
pgOut, err := postgres.NewPostgreSQL(in.DbInput)
Expand Down
2 changes: 1 addition & 1 deletion framework/components/don/clnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Output struct {
}

func NewBasicDON(in *Input, bcOut *blockchain.Output, fakeUrl string) (*Output, error) {
if in.Out != nil && framework.NoCache() {
if in.Out != nil && framework.UseCache() {
return in.Out, nil
}
nodeOuts := make([]*clnode.Output, 0)
Expand Down
5 changes: 4 additions & 1 deletion framework/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
)

func NoCache() bool {
func UseCache() bool {
return os.Getenv("CTF_USE_CACHED_OUTPUTS") == "true"
}

Expand All @@ -21,6 +21,9 @@ func getBaseConfigPath() (string, error) {
}

func Store[T any](cfg *T) error {
if UseCache() {
return nil
}
baseConfigPath, err := getBaseConfigPath()
if err != nil {
return err
Expand Down
3 changes: 3 additions & 0 deletions framework/promtail.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ scrape_configs:
}

func NewLokiStreamer() error {
if UseCache() {
return nil
}
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
defer cancel()

Expand Down

0 comments on commit 68f7476

Please sign in to comment.