github.com/tsuna/gohbase@v0.0.0-20250731002811-4ffcadfba63e/hrpc/enable.go (about)

     1  // Copyright (C) 2015  The GoHBase Authors.  All rights reserved.
     2  // This file is part of GoHBase.
     3  // Use of this source code is governed by the Apache License 2.0
     4  // that can be found in the COPYING file.
     5  
     6  package hrpc
     7  
     8  import (
     9  	"context"
    10  
    11  	"github.com/tsuna/gohbase/pb"
    12  	"google.golang.org/protobuf/proto"
    13  )
    14  
    15  // EnableTable represents a EnableTable HBase call
    16  type EnableTable struct {
    17  	base
    18  }
    19  
    20  // NewEnableTable creates a new EnableTable request that will enable the
    21  // given table in HBase. For use by the admin client.
    22  func NewEnableTable(ctx context.Context, table []byte) *EnableTable {
    23  	return &EnableTable{
    24  		base{
    25  			table:    table,
    26  			ctx:      ctx,
    27  			resultch: make(chan RPCResult, 1),
    28  		},
    29  	}
    30  }
    31  
    32  // Name returns the name of this RPC call.
    33  func (et *EnableTable) Name() string {
    34  	return "EnableTable"
    35  }
    36  
    37  // Description returns the description of this RPC call.
    38  func (et *EnableTable) Description() string {
    39  	return et.Name()
    40  }
    41  
    42  // ToProto converts the RPC into a protobuf message
    43  func (et *EnableTable) ToProto() proto.Message {
    44  	return &pb.EnableTableRequest{
    45  		TableName: &pb.TableName{
    46  			// TODO: handle namespaces
    47  			Namespace: []byte("default"),
    48  			Qualifier: et.table,
    49  		},
    50  	}
    51  }
    52  
    53  // NewResponse creates an empty protobuf message to read the response of this
    54  // RPC.
    55  func (et *EnableTable) NewResponse() proto.Message {
    56  	return &pb.EnableTableResponse{}
    57  }