Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metrics #76

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion acl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ go 1.18

replace (
go.osspkg.com/goppy/errors => ../errors
go.osspkg.com/goppy/syscall => ../syscall
go.osspkg.com/goppy/xtest => ../xtest
)

require (
go.osspkg.com/goppy/errors v0.1.1
go.osspkg.com/goppy/errors v0.1.2
go.osspkg.com/goppy/xtest v0.1.4
)

require go.osspkg.com/goppy/syscall v0.1.3 // indirect
6 changes: 2 additions & 4 deletions app/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ package app

import (
"go.osspkg.com/goppy/console"
"go.osspkg.com/goppy/env"
"go.osspkg.com/goppy/iofile"
"go.osspkg.com/goppy/syscall"
"go.osspkg.com/goppy/xc"
"go.osspkg.com/goppy/xlog"
)

type (
//ENV type for environments (prod, dev, stage, etc)
ENV string

App interface {
Logger(log xlog.Logger) App
Modules(modules ...interface{}) App
Expand Down Expand Up @@ -191,7 +189,7 @@ func (a *_app) prepareConfig(interactive bool) {
}
a.logout.Handler(a.log)
a.modules = a.modules.Add(
ENV(config.Env),
env.ENV(config.Env),
)
// decode all configs
var configs []interface{}
Expand Down
10 changes: 6 additions & 4 deletions app/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.18

replace (
go.osspkg.com/goppy/console => ../console
go.osspkg.com/goppy/env => ../env
go.osspkg.com/goppy/errors => ../errors
go.osspkg.com/goppy/iofile => ../iofile
go.osspkg.com/goppy/iosync => ../iosync
Expand All @@ -15,11 +16,12 @@ replace (

require (
go.osspkg.com/algorithms v1.3.1
go.osspkg.com/goppy/console v0.1.1
go.osspkg.com/goppy/errors v0.1.1
go.osspkg.com/goppy/iofile v0.1.5
go.osspkg.com/goppy/console v0.1.2
go.osspkg.com/goppy/env v0.1.2
go.osspkg.com/goppy/errors v0.1.2
go.osspkg.com/goppy/iofile v0.1.6
go.osspkg.com/goppy/iosync v0.1.5
go.osspkg.com/goppy/syscall v0.1.2
go.osspkg.com/goppy/syscall v0.1.3
go.osspkg.com/goppy/xc v0.1.1
go.osspkg.com/goppy/xlog v0.1.7
go.osspkg.com/goppy/xtest v0.1.4
Expand Down
2 changes: 1 addition & 1 deletion app/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
go.osspkg.com/algorithms v1.3.1 h1:Weh0Z4dMzHFRJTfMva/mU6Uk95wSRGwt1Saj2sfz3Wc=
go.osspkg.com/algorithms v1.3.1/go.mod h1:kj+oVK7UDQlXMKleMTYzbEEpUAXC2tzRBtki7F5EbXc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
17 changes: 9 additions & 8 deletions auth/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ replace (

require (
github.com/mailru/easyjson v0.7.7
go.osspkg.com/goppy/encryption v0.1.5
go.osspkg.com/goppy/errors v0.1.1
go.osspkg.com/goppy/ioutil v0.1.2
go.osspkg.com/goppy/encryption v0.1.6
go.osspkg.com/goppy/errors v0.1.2
go.osspkg.com/goppy/ioutil v0.1.3
go.osspkg.com/goppy/plugins v0.1.2
go.osspkg.com/goppy/random v0.1.2
go.osspkg.com/goppy/web v0.1.10
go.osspkg.com/goppy/web v0.1.11
go.osspkg.com/goppy/xtest v0.1.4
golang.org/x/oauth2 v0.13.0
golang.org/x/oauth2 v0.16.0
)

require (
Expand All @@ -34,11 +34,12 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/josharian/intern v1.0.0 // indirect
go.osspkg.com/goppy/iosync v0.1.5 // indirect
go.osspkg.com/goppy/syscall v0.1.3 // indirect
go.osspkg.com/goppy/xc v0.1.1 // indirect
go.osspkg.com/goppy/xlog v0.1.7 // indirect
go.osspkg.com/goppy/xnet v0.1.2 // indirect
go.osspkg.com/goppy/xnet v0.1.3 // indirect
go.osspkg.com/static v1.4.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/net v0.20.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
)
14 changes: 8 additions & 6 deletions auth/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
go.osspkg.com/goppy/syscall v0.1.2 h1:g1qvlqHPBSDkF0un3gC2hpBqHZJfq9uwhSjmNRxbj0c=
go.osspkg.com/goppy/syscall v0.1.2/go.mod h1:8MsNFOYAzNzGI6FE+0hmqLINQ5cxVkhqHUyirzENG9A=
go.osspkg.com/static v1.4.0 h1:2uy4/11c0QP+QLMucKQZbAU+e6lhVHKw5dWJPTk/DBg=
go.osspkg.com/static v1.4.0/go.mod h1:94YydVU3qUtb1J534486lpm+qg6CviQjqtxKlkpSppM=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY=
golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ=
golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand All @@ -32,6 +34,6 @@ google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
9 changes: 7 additions & 2 deletions console/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ module go.osspkg.com/goppy/console

go 1.18

replace go.osspkg.com/goppy/errors => ../errors
replace (
go.osspkg.com/goppy/errors => ../errors
go.osspkg.com/goppy/syscall => ../syscall
)

require go.osspkg.com/goppy/errors v0.1.1
require go.osspkg.com/goppy/errors v0.1.2

require go.osspkg.com/goppy/syscall v0.1.3 // indirect
19 changes: 11 additions & 8 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ go get -u go.osspkg.com/goppy

## Plugins

| Plugin | Comment | Import |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| **debug** | Profiling application (pprof) with HTTP access. | `web.WithHTTPDebug()` |
| **http** | Out of the box multi-server launch of web servers with separate routing. Grouping of routers with connection to a group of dedicated middleware. HTTP clients pool. | `web.WithHTTP()` `web.WithWebsocketServer()` `web.WithWebsocketClient()` `web.WithHTTPClient()` |
| **unixsocket** | Requests via unix socket. | `unix.WithServer()` `unix.WithClient()` |
| **database** | Multiple connection pools with MySQL, SQLite, Postgre databases (with automatic migration setup). | `database.WithMySQL()` `database.WithSQLite()` `database.WithPostgreSQL()` |
| **geoip** | Definition of geo-IP information. | `geoip.WithMaxMindGeoIP()` + `geoip.CloudflareMiddleware()` `geoip.MaxMindMiddleware()` |
| **oauth** | Authorization via OAuth provider (Yandex, Google). JWT Cookie. | `auth.WithOAuth()` `auth.WithJWT()` `auth.JWTGuardMiddleware()` |
| Plugin | Comment | Import |
|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **metrics** | Profiling application (pprof) and metrics collection (prometheus) with access via HTTP. | `go.osspkg.com/goppy/metrics`<br/> `metrics.WithMetrics()` |
| **http** | Out of the box multi-server launch of web servers with separate routing. Grouping of routers with connection to a group of dedicated middleware. HTTP clients pool. | `go.osspkg.com/goppy/web`<br/> `web.WithHTTP()`<br/> `web.WithHTTPClient()` |
| **websocket** | Ready-made websocket handler for server and client. Websocket server pool. | `go.osspkg.com/goppy/ws`<br/> `ws.WithWebsocketServer()`<br/> `ws.WithWebsocketClient()`<br/> `ws.WithWebsocketServerPool()` |
| **unixsocket** | Requests via unix socket. | `go.osspkg.com/goppy/unix`<br/> `unix.WithServer()`<br/> `unix.WithClient()` |
| **database** | Multiple connection pools with MySQL, SQLite, Postgre databases (with automatic migration setup). | `go.osspkg.com/goppy/ormmysql`<br/> `ormmysql.WithMySQL()` <br/> <br/> `go.osspkg.com/goppy/ormsqlite`<br/> `ormsqlite.WithSQLite()`<br/> <br/> `go.osspkg.com/goppy/ormpgsql`<br/> `ormpgsql.WithPostgreSQL()` |
| **geoip** | Definition of geo-IP information. | `go.osspkg.com/goppy/geoip`<br/> `geoip.WithMaxMindGeoIP()` + `geoip.CloudflareMiddleware()`<br/> `geoip.MaxMindMiddleware()` |
| **oauth** | Authorization via OAuth provider (Yandex, Google). JWT Cookie. | `go.osspkg.com/goppy/metrics`<br/> `auth.WithOAuth()`<br/> `auth.WithJWT()` + `auth.JWTGuardMiddleware()` |

## Quick Start

Expand Down Expand Up @@ -65,6 +66,8 @@ func main() {
// Specify the path to the config via the argument: `--config`.
// Specify the path to the pidfile via the argument: `--pid`.
app := goppy.New()
app.AppName("demo_app")
app.AppVersion("v1.0.0")
app.Plugins(
web.WithHTTP(),
)
Expand Down
7 changes: 5 additions & 2 deletions encryption/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ go 1.18
replace (
go.osspkg.com/goppy/errors => ../errors
go.osspkg.com/goppy/random => ../random
go.osspkg.com/goppy/syscall => ../syscall
go.osspkg.com/goppy/xtest => ../xtest
)

require (
go.osspkg.com/goppy/errors v0.1.1
go.osspkg.com/goppy/errors v0.1.2
go.osspkg.com/goppy/random v0.1.2
go.osspkg.com/goppy/xtest v0.1.4
golang.org/x/crypto v0.17.0
golang.org/x/crypto v0.18.0
)

require go.osspkg.com/goppy/syscall v0.1.3 // indirect
4 changes: 2 additions & 2 deletions encryption/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
29 changes: 29 additions & 0 deletions env/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2022-2024 Mikhail Knyazhev <markus621@yandex.ru>. All rights reserved.
* Use of this source code is governed by a BSD 3-Clause license that can be found in the LICENSE file.
*/

package env

type (
//ENV type for environments (prod, dev, stage, etc)
ENV string

AppName string
AppVersion string
AppDescription string

AppInfo struct {
AppName AppName
AppVersion AppVersion
AppDescription AppDescription
}
)

func NewAppInfo() AppInfo {
return AppInfo{
AppName: "",
AppVersion: "",
AppDescription: "",
}
}
8 changes: 5 additions & 3 deletions epoll/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@ go 1.18
replace (
go.osspkg.com/goppy/errors => ../errors
go.osspkg.com/goppy/iosync => ../iosync
go.osspkg.com/goppy/syscall => ../syscall
go.osspkg.com/goppy/xc => ../xc
go.osspkg.com/goppy/xlog => ../xlog
go.osspkg.com/goppy/xnet => ../xnet
go.osspkg.com/goppy/xtest => ../xtest
)

require (
go.osspkg.com/goppy/errors v0.1.1
go.osspkg.com/goppy/errors v0.1.2
go.osspkg.com/goppy/iosync v0.1.5
go.osspkg.com/goppy/xc v0.1.1
go.osspkg.com/goppy/xlog v0.1.7
go.osspkg.com/goppy/xnet v0.1.2
golang.org/x/sys v0.15.0
go.osspkg.com/goppy/xnet v0.1.3
golang.org/x/sys v0.16.0
)

require (
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
go.osspkg.com/goppy/syscall v0.1.3 // indirect
)
4 changes: 2 additions & 2 deletions epoll/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
4 changes: 3 additions & 1 deletion errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ package errors
import (
e "errors"
"fmt"

"go.osspkg.com/goppy/syscall"
)

type err struct {
Expand Down Expand Up @@ -39,7 +41,7 @@ func (v *err) Unwrap() error {
}

func (v *err) WithTrace() {
v.trace = tracing()
v.trace = syscall.Trace(10)
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 4 additions & 0 deletions errors/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
module go.osspkg.com/goppy/errors

go 1.18

replace go.osspkg.com/goppy/syscall => ../syscall

require go.osspkg.com/goppy/syscall v0.1.3
Loading
Loading