コード例 #1
0
ファイル: server.go プロジェクト: yarpc/yarpc-go
// New prepares an implementation of the ThriftTest service for
// registration.
//
// 	handler := ThriftTestHandler{}
// 	dispatcher.Register(thrifttestserver.New(handler))
func New(impl Interface, opts ...thrift.RegisterOption) []transport.Registrant {
	h := handler{impl}
	service := thrift.Service{
		Name: "ThriftTest",
		Methods: map[string]thrift.UnaryHandler{
			"testBinary":         thrift.UnaryHandlerFunc(h.TestBinary),
			"testByte":           thrift.UnaryHandlerFunc(h.TestByte),
			"testDouble":         thrift.UnaryHandlerFunc(h.TestDouble),
			"testEnum":           thrift.UnaryHandlerFunc(h.TestEnum),
			"testException":      thrift.UnaryHandlerFunc(h.TestException),
			"testI32":            thrift.UnaryHandlerFunc(h.TestI32),
			"testI64":            thrift.UnaryHandlerFunc(h.TestI64),
			"testInsanity":       thrift.UnaryHandlerFunc(h.TestInsanity),
			"testList":           thrift.UnaryHandlerFunc(h.TestList),
			"testMap":            thrift.UnaryHandlerFunc(h.TestMap),
			"testMapMap":         thrift.UnaryHandlerFunc(h.TestMapMap),
			"testMulti":          thrift.UnaryHandlerFunc(h.TestMulti),
			"testMultiException": thrift.UnaryHandlerFunc(h.TestMultiException),
			"testNest":           thrift.UnaryHandlerFunc(h.TestNest),

			"testSet":       thrift.UnaryHandlerFunc(h.TestSet),
			"testString":    thrift.UnaryHandlerFunc(h.TestString),
			"testStringMap": thrift.UnaryHandlerFunc(h.TestStringMap),
			"testStruct":    thrift.UnaryHandlerFunc(h.TestStruct),
			"testTypedef":   thrift.UnaryHandlerFunc(h.TestTypedef),
			"testVoid":      thrift.UnaryHandlerFunc(h.TestVoid),
		},
		OnewayMethods: map[string]thrift.OnewayHandler{

			"testOneway": thrift.OnewayHandlerFunc(h.TestOneway),
		},
	}
	return thrift.BuildRegistrants(service, opts...)
}
コード例 #2
0
ファイル: server.go プロジェクト: yarpc/yarpc-go
// New prepares an implementation of the Oneway service for
// registration.
//
// 	handler := OnewayHandler{}
// 	dispatcher.Register(onewayserver.New(handler))
func New(impl Interface, opts ...thrift.RegisterOption) []transport.Registrant {
	h := handler{impl}
	service := thrift.Service{
		Name:    "Oneway",
		Methods: map[string]thrift.UnaryHandler{},
		OnewayMethods: map[string]thrift.OnewayHandler{
			"echo": thrift.OnewayHandlerFunc(h.Echo),
		},
	}
	return thrift.BuildRegistrants(service, opts...)
}