Example #1
0
// LoadRecord populates action.Record
func (action *AccountShowAction) LoadRecord() {
	action.LoadQuery()
	if action.Err != nil {
		return
	}

	action.Err = db.Get(action.Ctx, action.Query, &action.Record)
}
Example #2
0
// UpdateMetrics triggers a refresh of several metrics gauges, such as open
// db connections and ledger state
func (a *App) UpdateLedgerState() {
	var ls db.LedgerState
	q := db.LedgerStateQuery{a.HistoryQuery(), a.CoreQuery()}
	err := db.Get(context.Background(), q, &ls)

	if err != nil {
		log.WithStack(err).
			WithField("err", err.Error()).
			Error("failed to load ledger state")
		return
	}

	a.latestLedgerState = ls
}
Example #3
0
// JSON is a method for actions.JSON
func (action *LedgerShowAction) JSON() {
	query := action.Query()

	if action.Err != nil {
		return
	}

	action.Err = db.Get(action.Ctx, query, &action.Record)

	if action.Err != nil {
		return
	}

	hal.Render(action.W, NewLedgerResource(action.Record))
}
Example #4
0
// JSON is a method for actions.JSON
func (action *OperationShowAction) JSON() {
	query := action.Query()
	if action.Err != nil {
		return
	}

	action.Err = db.Get(action.Ctx, query, &action.Record)
	if action.Err != nil {
		return
	}

	r, err := NewOperationResource(action.Record)
	if err != nil {
		return
	}

	hal.Render(action.W, r)
}
Example #5
0
// UpdateMetrics triggers a refresh of several metrics gauges, such as open
// db connections and ledger state
func (a *App) UpdateMetrics(ctx context.Context) {

	a.goroutineGauge.Update(int64(runtime.NumGoroutine()))

	var ls db.LedgerState
	q := db.LedgerStateQuery{a.HistoryQuery(), a.CoreQuery()}
	err := db.Get(ctx, q, &ls)

	if err != nil {
		log.WithStack(ctx, err).
			WithField("err", err.Error()).
			Error("failed to load ledger state")
		return
	}

	a.horizonLedgerGauge.Update(int64(ls.HorizonSequence))
	a.stellarCoreLedgerGauge.Update(int64(ls.StellarCoreSequence))

	a.horizonConnGauge.Update(int64(a.historyDb.Stats().OpenConnections))
	a.stellarCoreConnGauge.Update(int64(a.coreDb.Stats().OpenConnections))
}
Example #6
0
func (action *LedgerShowAction) LoadRecord() {
	action.Err = db.Get(action.Ctx, action.Query, &action.Record)
}
Example #7
0
func (action *OperationShowAction) LoadRecord() {
	action.Err = db.Get(action.Ctx, action.Query, &action.Record)
}
Example #8
0
// LoadRecord populates action.Record
func (action *AccountShowAction) LoadRecord() {
	action.Err = db.Get(action.Ctx, action.Query, &action.Record)
}