Meter operations

Updated at:

You can use the DataHub Go SDK to query meter information such as active time and storage usage for a shard.

Parameters

Parameter name

Parameter type

Description

projectName

string

The name of the project.

topicName

string

The name of the topic.

shardId

string

The ID of the shard.

Response example

type GetMeterInfoResult struct {
    ActiveTime int64 `json:"ActiveTime"`
    Storage    int64 `json:"Storage"`
}

Error description

Error class

Error code

Description

ResourceNotFoundError

ResourceNotFound

NoSuchProject

NoSuchTopic

NoSuchShard

NoSuchSubscription

NoSuchConnector

NoSuchMeteringInfo

The specified resource does not exist. This error may occur when a request is sent immediately after a shard split or merge operation.

AuthorizationFailedError

Unauthorized

The authorization signature could not be parsed. Verify that your AccessKey is correct.

DatahubClientError

-

Base class for all other errors.

InvalidParameterError

InvalidParameter

InvalidCursor

An invalid parameter was specified.

Sample code

func meter(dh datahub.DataHub, projectName, topicName string) {
    shardId := "0"
    gmi, err := dh.GetMeterInfo(projectName, topicName, shardId)
    if err != nil {
        fmt.Println("get meter information failed")
        return
    }
    fmt.Println("get meter information successful")
    fmt.Println(gmi)
}