github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/meta/consumed_units.go (about)

     1  package meta
     2  
     3  import (
     4  	"strconv"
     5  
     6  	"google.golang.org/grpc/metadata"
     7  
     8  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/meta"
     9  )
    10  
    11  func ConsumedUnits(md metadata.MD) (consumedUnits uint64) {
    12  	for header, values := range md {
    13  		if header != meta.HeaderConsumedUnits {
    14  			continue
    15  		}
    16  		for _, v := range values {
    17  			v, err := strconv.ParseUint(v, 10, 64)
    18  			if err == nil {
    19  				consumedUnits += v
    20  			}
    21  		}
    22  	}
    23  
    24  	return consumedUnits
    25  }