Skip to content

Commit

Permalink
add App methods
Browse files Browse the repository at this point in the history
  • Loading branch information
josuebrunel committed May 20, 2023
1 parent 1804653 commit 018dedc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ app := tellme.NewApp(
)

// Get Info
app.Info // returns a json serializable struct
app.GetInfo() // returns a json serializable struct
// Get Env
app.Env // returns map[string]string
app.GetEnv() // returns map[string]string
// Get Metrics
app.Metrics // returns a json serializable struct
app.GetMetrics() // returns a json serializable struct
// Get Threaddump
app.Threaddump // returns a string
app.GetThreadDump() // returns []byte
```
16 changes: 16 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ type App struct {
Threaddump []byte `json:"threaddump"`
}

func (a App) GetEnv() map[string]string {
return a.Env
}

func (a App) GetInfo() InfoParams {
return a.Info
}

func (a App) GetMetrics() MemStats {
return a.Metrics
}

func (a App) GetThreadDump() []byte {
return a.Threaddump
}

func NewApp(env, name, version, buildStamp, commitAuthor, commitID, commitTime, commitBranch string) App {
info := InfoParams{
EnvName: env,
Expand Down
7 changes: 7 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,11 @@ func TestApp(t *testing.T) {
t.Fatalf("[ASSERT-ERROR] expected %s but got %s\n", archVersion, app.Info.RuntimeVersion)
}
})

t.Run("All", func(t *testing.T) {
app.GetInfo()
app.GetEnv()
app.GetMetrics()
app.GetThreadDump()
})
}

0 comments on commit 018dedc

Please sign in to comment.