Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4260

Go context generation issue. Context is parameter in Interface not in implementation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 0.11.0
    • 0.11.0
    • Go - Compiler
    • None

    Description

      Unfortunately the Go library was updated before a new Compiler was released. Having thrift compiled code be part in a project prior to the thrift context library addition breaks due to the dependency on the thrift go library. See: https://github.com/openzipkin/zipkin-go-opentracing/issues/68

      I tried to resolve be installing compiler from latest source but found the generated source to be incorrect. The generated Go interface for the service client includes context.Context as the first parameter of the service method. The generated client implementation however does not.

      The following thrift code:

      enum ResultCode
      {
        OK,
        TRY_LATER
      }
      
      struct LogEntry
      {
        1:  string category,
        2:  string message
      }
      
      service Scribe
      {
        ResultCode Log(1: list<LogEntry> messages);
      }
      

      Generated the following Go code:

      type Scribe interface {
      	// Parameters:
      	//  - Messages
      	Log(ctx context.Context, messages []*LogEntry) (r ResultCode, err error)
      }
      
      ...
      
      // Parameters:
      //  - Messages
      func (p *ScribeClient) Log(messages []*LogEntry) (r ResultCode, err error) {
      	if err = p.sendLog(messages); err != nil {
      		return
      	}
      	return p.recvLog()
      }
      
      

      Attachments

        Issue Links

          Activity

            People

              taozle taozle
              basvanbeek Bas van Beek
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: