Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Assignment 1
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Aksel Baardsen
Assignment 1
Commits
12827928
Commit
12827928
authored
5 years ago
by
Aksel Baardsen
Browse files
Options
Downloads
Patches
Plain Diff
fixed app uptime
parent
e4be5e7e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.go
+0
-1
0 additions, 1 deletion
main.go
pkg/diag.go
+13
-8
13 additions, 8 deletions
pkg/diag.go
with
13 additions
and
9 deletions
main.go
+
0
−
1
View file @
12827928
...
...
@@ -9,7 +9,6 @@ import (
"net/http"
)
//returns json ready for parsing as string
func
main
()
{
...
...
This diff is collapsed.
Click to expand it.
pkg/diag.go
+
13
−
8
View file @
12827928
...
...
@@ -3,17 +3,21 @@ package pkg
import
(
"log"
"net/http"
"time"
)
const
gbifApi
=
"http://api.gbif.org/v1/"
const
restApi
=
"https://restcountries.eu/rest/v2"
var
startTime
time
.
Time
type
Diag
struct
{
func
init
()
{
startTime
=
time
.
Now
()
}
type
Diag
struct
{
Gbif
int
`json:"gbif"`
Restcountries
int
`json:"restcountries"`
Version
string
`json:"version"`
Uptime
string
`json:"uptime"`
Uptime
float64
`json:"uptime"`
}
func
GetDiag
(
d
*
Diag
)
{
...
...
@@ -23,7 +27,6 @@ func GetDiag(d* Diag) {
getUptime
(
d
)
}
func
getGbifStatus
(
d
*
Diag
)
{
resp
,
err
:=
http
.
Get
(
gbifApi
)
if
err
!=
nil
{
...
...
@@ -44,6 +47,8 @@ func getVersion(d *Diag) {
d
.
Version
=
"v1"
}
// Returns application uptime in seconds
func
getUptime
(
d
*
Diag
)
{
d
.
Uptime
=
"42sec"
up
:=
time
.
Since
(
startTime
)
.
Seconds
()
d
.
Uptime
=
up
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment