This file contains hidden or 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
GET http://localhost:8888/ |
This file contains hidden or 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
package main | |
import ( | |
"log" | |
"net/http" | |
) | |
var limiter = NewIPRateLimiter(1, 5) | |
func main() { |
This file contains hidden or 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
package main | |
import ( | |
"sync" | |
"golang.org/x/time/rate" | |
) | |
// IPRateLimiter . | |
type IPRateLimiter struct { |
This file contains hidden or 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
package main | |
import ( | |
"log" | |
"net/http" | |
) | |
func main() { | |
mux := http.NewServeMux() | |
mux.HandleFunc("/", okHandler) |
This file contains hidden or 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
<template> | |
<apexchart type="radialBar" :options="options" :series="series"></apexchart> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { | |
series: [0], | |
options: { | |
labels: ['CPU Usage'] |
This file contains hidden or 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
mounted: function() { | |
wails.events.on("cpu_usage", cpu_usage => { | |
if (cpu_usage) { | |
console.log(cpu_usage.avg); | |
} | |
}); | |
} |
This file contains hidden or 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
func (s *Stats) WailsInit(runtime *wails.Runtime) error { | |
s.log = runtime.Log.New("Stats") | |
go func() { | |
for { | |
runtime.Events.Emit("cpu_usage", s.GetCPUUsage()) | |
time.Sleep(1 * time.Second) | |
} | |
}() | |
return nil | |
} |
This file contains hidden or 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
window.backend.Stats.GetCPUUsage().then(cpu_usage => { | |
console.log(cpu_usage); | |
}) |
This file contains hidden or 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
package main | |
import ( | |
"github.com/leaanthony/mewn" | |
"github.com/plutov/packagemain/cpustats/pkg/sys" | |
"github.com/wailsapp/wails" | |
) | |
func main() { | |
js := mewn.String("./frontend/dist/app.js") | |
css := mewn.String("./frontend/dist/app.css") | |
stats := &sys.Stats{} |
This file contains hidden or 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
package sys | |
import ( | |
"math" | |
"time" | |
"github.com/shirou/gopsutil/cpu" | |
"github.com/wailsapp/wails" | |
) | |
// Stats . | |
type Stats struct { | |
log *wails.CustomLogger |