-
Notifications
You must be signed in to change notification settings - Fork 4
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 #5 from caas-team/feat/cfg-loader
Feat/cfg loader
- Loading branch information
Showing
12 changed files
with
255 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,6 @@ jobs: | |
- name: Test | ||
run: | | ||
go mod download | ||
go install github.com/matryer/[email protected] | ||
go generate ./... | ||
go test --race --coverprofile cover.out -v ./... |
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 |
---|---|---|
|
@@ -20,3 +20,6 @@ | |
# Go workspace file | ||
go.work | ||
gen | ||
|
||
# generated interface mock files | ||
*_moq.go |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package sparrow | ||
package config | ||
|
||
type Config struct { | ||
Checks map[string]any | ||
|
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,26 @@ | ||
package config | ||
|
||
import "context" | ||
|
||
type HttpLoader struct { | ||
cfg *Config | ||
cCfgChecks chan<- map[string]any | ||
} | ||
|
||
func NewHttpLoader(cfg *Config, cCfgChecks chan<- map[string]any) *HttpLoader { | ||
return &HttpLoader{ | ||
cfg: cfg, | ||
cCfgChecks: cCfgChecks, | ||
} | ||
} | ||
|
||
func (gl *HttpLoader) Run(ctx context.Context) { | ||
// Get cfg from gitlab | ||
// check cfg has changed | ||
// send signal | ||
|
||
// cfg has changed | ||
gl.cCfgChecks <- map[string]any{ | ||
"rtt": "check cfg to set dynamically", | ||
} | ||
} |
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,18 @@ | ||
package config | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
const ( | ||
gitlabLoader = "GITLAB" | ||
localLoader = "LOCAL" | ||
) | ||
|
||
type Loader interface { | ||
Run(context.Context) | ||
} | ||
|
||
func NewLoader(cfg *Config, cCfgChecks chan<- map[string]any) Loader { | ||
return NewHttpLoader(cfg, cCfgChecks) | ||
} |
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.