github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/pkg/sys/builtin/impl_grcount.go (about)

     1  /*
     2   * Copyright (c) 2021-present unTill Pro, Ltd.
     3   */
     4  
     5  package builtin
     6  
     7  import (
     8  	"context"
     9  	"runtime"
    10  
    11  	"github.com/voedger/voedger/pkg/appdef"
    12  	"github.com/voedger/voedger/pkg/istructs"
    13  	istructsmem "github.com/voedger/voedger/pkg/istructsmem"
    14  )
    15  
    16  type grcountRR struct {
    17  	istructs.NullObject
    18  }
    19  
    20  func (e *grcountRR) AsInt32(string) int32 { return int32(runtime.NumGoroutine()) }
    21  
    22  func provideQryGRCount(cfg *istructsmem.AppConfigType) {
    23  	cfg.Resources.Add(istructsmem.NewQueryFunction(
    24  		appdef.NewQName(appdef.SysPackage, "GRCount"),
    25  		func(_ context.Context, _ istructs.ExecQueryArgs, callback istructs.ExecQueryCallback) (err error) {
    26  			return callback(&grcountRR{})
    27  		},
    28  	))
    29  }