feat: Add node uptime rpc / output in info command

This commit is contained in:
Łukasz Magiera
2022-10-11 10:11:09 +02:00
parent e74838f024
commit 2c11f9d265
17 changed files with 119 additions and 0 deletions
+1
View File
@@ -155,6 +155,7 @@ func defaults() []Option {
Override(new(journal.DisabledEvents), journal.EnvDisabledEvents),
Override(new(journal.Journal), modules.OpenFilesystemJournal),
Override(new(*alerting.Alerting), alerting.NewAlertingSystem),
Override(new(dtypes.NodeStartTime), FromVal(dtypes.NodeStartTime(time.Now()))),
Override(CheckFDLimit, modules.CheckFdLimit(build.DefaultFDLimit)),
+7
View File
@@ -2,6 +2,7 @@ package common
import (
"context"
"time"
"github.com/gbrlsnchs/jwt/v3"
"github.com/google/uuid"
@@ -26,6 +27,8 @@ type CommonAPI struct {
Alerting *alerting.Alerting
APISecret *dtypes.APIAlg
ShutdownChan dtypes.ShutdownChan
Start dtypes.NodeStartTime
}
type jwtPayload struct {
@@ -91,3 +94,7 @@ func (a *CommonAPI) Session(ctx context.Context) (uuid.UUID, error) {
func (a *CommonAPI) Closing(ctx context.Context) (<-chan struct{}, error) {
return make(chan struct{}), nil // relies on jsonrpc closing
}
func (a *CommonAPI) StartTime(context.Context) (time.Time, error) {
return time.Time(a.Start), nil
}
+4
View File
@@ -1,6 +1,8 @@
package dtypes
import (
"time"
"github.com/gbrlsnchs/jwt/v3"
"github.com/multiformats/go-multiaddr"
)
@@ -8,3 +10,5 @@ import (
type APIAlg jwt.HMACSHA
type APIEndpoint multiaddr.Multiaddr
type NodeStartTime time.Time
+6
View File
@@ -93,6 +93,12 @@ func From(typ interface{}) interface{} {
}).Interface()
}
func FromVal[T any](v T) func() T {
return func() T {
return v
}
}
// from go-ipfs
// as casts input constructor to a given interface (if a value is given, it
// wraps it into a constructor).