package metadb

import (
	"context"
	tenants "github.com/tidbcloud/grpc-metadb-client/gen/idl/tenant"
	"google.golang.org/grpc"

	"log"
)

// @Time    : 2022/7/26 2:44 PM
// @Author  : lvhongmeng
type TenantClient struct {
	Client tenants.TenantClient
	Biz    string
}

func NewTenantClient(biz string, conn *grpc.ClientConn) *TenantClient {
	client := tenants.NewTenantClient(conn)
	tenantClient := &TenantClient{
		Client: client,
		Biz:    biz,
	}
	return tenantClient
}

func (c *TenantClient) GetTenantsV1(id int64) (*tenants.TenantsReply, error) {
	log.Printf("biz:%s use GetTenantsV1", c.Biz)
	return c.Client.GetTenantsV1(context.Background(), &tenants.TenantsRequest{Id: id})
}
