feat: Add node uptime rpc / output in info command
This commit is contained in:
@@ -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)),
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user