github.com/sanposhiho/openapi2proto@v0.0.0-20230521044535-d1080a134e37/protobuf/rpc.go (about)

     1  package protobuf
     2  
     3  // NewRPC creates a new RPC object
     4  func NewRPC(name string) *RPC {
     5  	return &RPC{
     6  		name: name,
     7  		parameter: emptyMessage,
     8  		response: emptyMessage,
     9  	}
    10  }
    11  
    12  // Name returns the name of this rpc call
    13  func (r *RPC) Name() string {
    14  	return r.name
    15  }
    16  
    17  // Parameter returns the type of parameter message
    18  func (r *RPC) Parameter() Type {
    19  	return r.parameter
    20  }
    21  
    22  // Response returns the type of response message
    23  func (r *RPC) Response() Type {
    24  	return r.response
    25  }
    26  
    27  // Comment returns the comment string associated with the RPC
    28  func (r *RPC) Comment() string {
    29  	return r.comment
    30  }
    31  
    32  // SetParameter sets the parameter type
    33  func (r *RPC) SetParameter(m *Message) {
    34  	r.parameter = m
    35  }
    36  
    37  // SetResponse sets the response type
    38  func (r *RPC) SetResponse(m *Message) {
    39  	r.response = m
    40  }
    41  
    42  // SetComment sets the comment
    43  func (r *RPC) SetComment(s string) {
    44  	r.comment = s
    45  }
    46  
    47  // AddOption adds rpc options to the RPC
    48  func (r *RPC) AddOption(v interface{}) {
    49  	r.options = append(r.options, v)
    50  }