type FooServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction handler FooService } func (p *FooServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { p.processorMap[key] = processor } func (p *FooServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { processor, ok = p.processorMap[key] return processor, ok } func (p *FooServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { return p.processorMap } func NewFooServiceProcessor(handler FooService) *FooServiceProcessor { self2 := &FooServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} self2.processorMap["add1"] = &fooServiceProcessorAdd1{handler: handler} return self2 } func (p *FooServiceProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { name, _, seqId, err := iprot.ReadMessageBegin() if err != nil { return false, err } if processor, ok := p.GetProcessorFunction(name); ok { return processor.Process(seqId, iprot, oprot) } //unchanged... } type fooServiceProcessorAdd1 struct { handler FooService } func (p *fooServiceProcessorAdd1) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { //Body Unaffected }