You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: backup_size.go
    path of file: ./repos/tidb-operator/cmd/backup-manager/app/util
    
    the code of the file until where you have to start completion: // Copyright 2023 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

package util

import (
	"context"
	"encoding/json"
	"fmt"
	"sort"
	"strings"
	"sync/atomic"
	"time"

	"github.com/aws/aws-sdk-go/aws"
	"git
    
func calculateSnapshotSize(volumeId, snapshotId string) (uint64, uint64, error) {
	var snapshotSize uint64
	var numApiReq uint64

	start := time.Now()

	klog.Infof("start to calculate size for snapshot %s, volume %s",
		snapshotId, volumeId)

	ebsSession, err := util.NewEBSSession(util.CloudAPIConcurrency)
	if err != nil {
		klog.Errorf("new a ebs session failure.")
		return 0, numApiReq, err
	}

	var nextToken *string
	for {
		// Each retry interval is around 1 second, and no more than 60 times retry (~1 minute)
		backoff := wait.Backoff{
			Duration: time.Second,
			Steps:    60,
			Factor:   1.0,
			Jitter:   0.1,
		}

		isAllListed := false

		listBlocks := func() error {
			resp, err := ebsSession.EBS.ListSnapshotBlocks(&ebs.ListSnapshotBlocksInput{
				SnapshotId: aws.String(snapshotId),
				MaxResults: aws.Int64(ListSnapMaxReturnResult),
				NextToken:  nextToken,
			})
			numApiReq += 1
			if err != nil {
				return err
			}
			if resp.BlockSize != nil {
				snapshotSize += uint64(len(resp.Blocks)) * uint64(*resp.BlockSize)
			}

			// check if there is more to retrieve
			if resp.NextToken == nil {
				isAllListed = true
			}
			nextToken = resp.NextToken

			return nil
		}

		isRetry := func(err error) bool {
			return request.IsErrorThrottle(err)
		}
		err = retry.OnError(backoff, isRetry, listBlocks)

		if err != nil {
			return 0, numApiReq, errors.Annotatef(err, "ListSnapshotBlocks() failed against snapshot id %s, volume id %s", snapshotId, volumeId)
		}

		if isAllListed {
			break
		}
	}

	elapsed := time.Since(start)

	klog.Infof("full snapshot size %s, num of ListSnapshotBlocks request %d, snapshot id %s, volume id %s, takes %v",
		humanize.Bytes(snapshotSize), numApiReq, snapshotId, volumeId, elapsed)

	return snapshotSize, numApiReq, nil
}