Rearranged things to be logically structured, go generate to create proto rather than external tooling (other than protoc).

This commit is contained in:
David Vennik
2022-03-14 13:10:44 +02:00
parent 8be33410f3
commit 305939047c
7 changed files with 496 additions and 87 deletions

View File

@@ -1,39 +0,0 @@
OS := $(shell sh -c 'uname -s 2>/dev/null || echo linux' | tr "[:upper:]" "[:lower:]")
PROTOC := $(shell which protoc)
platform = ubuntu-latest
# Protobuf compiler (aka Protoc)
ifeq ($(OS), linux)
protoc=protoc-3.14.0-linux-x86_64.zip
endif
ifeq ($(OS), darwin)
protoc = protoc-3.14.0-osx-x86_64.zip
platform = macos-latest
endif
schema:
ifeq (,$(wildcard ./tmp/protoc/bin/protoc))
make protoc
endif
./tmp/protoc/bin/protoc --proto_path=./schema ./schema/bls12381sig.proto \
--go_opt=paths=source_relative \
--go_out=plugins=grpc:./go/bls/grpc/; \
protoc:
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/$(protoc)
mkdir -p ./tmp/protoc
unzip -o $(protoc) -d ./tmp/protoc bin/protoc
unzip -o $(protoc) -d ./tmp/protoc 'include/*'
rm -f $(protoc)
go install google.golang.org/grpc@v1.42.0
go install github.com/golang/protobuf/protoc-gen-go@latest
memprofile:
go test -run=. -bench=. -benchtime=5s -count 1 -benchmem -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out ./... | tee bench.txt
go tool pprof -http :8081 mem.out
benchmem: build test
go test -run=. -bench=. -benchtime=5s -count 1 -benchmem ./...
clean:
rm -rf ./tmp

5
go.mod
View File

@@ -2,6 +2,9 @@ module github.com/quanterall/kitchensink
go 1.17
require lukechampine.com/blake3 v1.1.7
require (
google.golang.org/protobuf v1.27.1
lukechampine.com/blake3 v1.1.7
)
require github.com/klauspost/cpuid/v2 v2.0.9 // indirect

8
go.sum
View File

@@ -1,4 +1,12 @@
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0=
lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA=

477
service/api/based32.pb.go Normal file
View File

@@ -0,0 +1,477 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.12.4
// source: api/based32.proto
package api
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Error int32
const (
Error_ZERO_LENGTH Error = 0
Error_CHECK_FAILED Error = 1
)
// Enum value maps for Error.
var (
Error_name = map[int32]string{
0: "ZERO_LENGTH",
1: "CHECK_FAILED",
}
Error_value = map[string]int32{
"ZERO_LENGTH": 0,
"CHECK_FAILED": 1,
}
)
func (x Error) Enum() *Error {
p := new(Error)
*p = x
return p
}
func (x Error) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (Error) Descriptor() protoreflect.EnumDescriptor {
return file_api_based32_proto_enumTypes[0].Descriptor()
}
func (Error) Type() protoreflect.EnumType {
return &file_api_based32_proto_enumTypes[0]
}
func (x Error) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use Error.Descriptor instead.
func (Error) EnumDescriptor() ([]byte, []int) {
return file_api_based32_proto_rawDescGZIP(), []int{0}
}
type EncodeRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data []byte `protobuf:"bytes,1,opt,name=Data,proto3" json:"Data,omitempty"`
}
func (x *EncodeRequest) Reset() {
*x = EncodeRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_api_based32_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EncodeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EncodeRequest) ProtoMessage() {}
func (x *EncodeRequest) ProtoReflect() protoreflect.Message {
mi := &file_api_based32_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use EncodeRequest.ProtoReflect.Descriptor instead.
func (*EncodeRequest) Descriptor() ([]byte, []int) {
return file_api_based32_proto_rawDescGZIP(), []int{0}
}
func (x *EncodeRequest) GetData() []byte {
if x != nil {
return x.Data
}
return nil
}
type EncodeResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Types that are assignable to Encoded:
// *EncodeResponse_EncodedString
// *EncodeResponse_Error
Encoded isEncodeResponse_Encoded `protobuf_oneof:"Encoded"`
}
func (x *EncodeResponse) Reset() {
*x = EncodeResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_api_based32_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EncodeResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EncodeResponse) ProtoMessage() {}
func (x *EncodeResponse) ProtoReflect() protoreflect.Message {
mi := &file_api_based32_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use EncodeResponse.ProtoReflect.Descriptor instead.
func (*EncodeResponse) Descriptor() ([]byte, []int) {
return file_api_based32_proto_rawDescGZIP(), []int{1}
}
func (m *EncodeResponse) GetEncoded() isEncodeResponse_Encoded {
if m != nil {
return m.Encoded
}
return nil
}
func (x *EncodeResponse) GetEncodedString() string {
if x, ok := x.GetEncoded().(*EncodeResponse_EncodedString); ok {
return x.EncodedString
}
return ""
}
func (x *EncodeResponse) GetError() Error {
if x, ok := x.GetEncoded().(*EncodeResponse_Error); ok {
return x.Error
}
return Error_ZERO_LENGTH
}
type isEncodeResponse_Encoded interface {
isEncodeResponse_Encoded()
}
type EncodeResponse_EncodedString struct {
EncodedString string `protobuf:"bytes,1,opt,name=EncodedString,proto3,oneof"`
}
type EncodeResponse_Error struct {
Error Error `protobuf:"varint,2,opt,name=Error,proto3,enum=signer.Error,oneof"`
}
func (*EncodeResponse_EncodedString) isEncodeResponse_Encoded() {}
func (*EncodeResponse_Error) isEncodeResponse_Encoded() {}
type DecodeRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
EncodedString string `protobuf:"bytes,1,opt,name=EncodedString,proto3" json:"EncodedString,omitempty"`
}
func (x *DecodeRequest) Reset() {
*x = DecodeRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_api_based32_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DecodeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DecodeRequest) ProtoMessage() {}
func (x *DecodeRequest) ProtoReflect() protoreflect.Message {
mi := &file_api_based32_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DecodeRequest.ProtoReflect.Descriptor instead.
func (*DecodeRequest) Descriptor() ([]byte, []int) {
return file_api_based32_proto_rawDescGZIP(), []int{2}
}
func (x *DecodeRequest) GetEncodedString() string {
if x != nil {
return x.EncodedString
}
return ""
}
type DecodeResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Types that are assignable to Decoded:
// *DecodeResponse_Data
// *DecodeResponse_Error
Decoded isDecodeResponse_Decoded `protobuf_oneof:"Decoded"`
}
func (x *DecodeResponse) Reset() {
*x = DecodeResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_api_based32_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DecodeResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DecodeResponse) ProtoMessage() {}
func (x *DecodeResponse) ProtoReflect() protoreflect.Message {
mi := &file_api_based32_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DecodeResponse.ProtoReflect.Descriptor instead.
func (*DecodeResponse) Descriptor() ([]byte, []int) {
return file_api_based32_proto_rawDescGZIP(), []int{3}
}
func (m *DecodeResponse) GetDecoded() isDecodeResponse_Decoded {
if m != nil {
return m.Decoded
}
return nil
}
func (x *DecodeResponse) GetData() []byte {
if x, ok := x.GetDecoded().(*DecodeResponse_Data); ok {
return x.Data
}
return nil
}
func (x *DecodeResponse) GetError() Error {
if x, ok := x.GetDecoded().(*DecodeResponse_Error); ok {
return x.Error
}
return Error_ZERO_LENGTH
}
type isDecodeResponse_Decoded interface {
isDecodeResponse_Decoded()
}
type DecodeResponse_Data struct {
Data []byte `protobuf:"bytes,1,opt,name=Data,proto3,oneof"`
}
type DecodeResponse_Error struct {
Error Error `protobuf:"varint,2,opt,name=Error,proto3,enum=signer.Error,oneof"`
}
func (*DecodeResponse_Data) isDecodeResponse_Decoded() {}
func (*DecodeResponse_Error) isDecodeResponse_Decoded() {}
var File_api_based32_proto protoreflect.FileDescriptor
var file_api_based32_proto_rawDesc = []byte{
0x0a, 0x11, 0x61, 0x70, 0x69, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x64, 0x33, 0x32, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x22, 0x23, 0x0a, 0x0d, 0x45,
0x6e, 0x63, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04,
0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61,
0x22, 0x6a, 0x0a, 0x0e, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x26, 0x0a, 0x0d, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x53, 0x74, 0x72,
0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0d, 0x45, 0x6e, 0x63,
0x6f, 0x64, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x25, 0x0a, 0x05, 0x45, 0x72,
0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x73, 0x69, 0x67, 0x6e,
0x65, 0x72, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x48, 0x00, 0x52, 0x05, 0x45, 0x72, 0x72, 0x6f,
0x72, 0x42, 0x09, 0x0a, 0x07, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x22, 0x35, 0x0a, 0x0d,
0x44, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a,
0x0d, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x53, 0x74, 0x72,
0x69, 0x6e, 0x67, 0x22, 0x58, 0x0a, 0x0e, 0x44, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x25, 0x0a, 0x05, 0x45,
0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x73, 0x69, 0x67,
0x6e, 0x65, 0x72, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x48, 0x00, 0x52, 0x05, 0x45, 0x72, 0x72,
0x6f, 0x72, 0x42, 0x09, 0x0a, 0x07, 0x44, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x2a, 0x2a, 0x0a,
0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x0f, 0x0a, 0x0b, 0x5a, 0x45, 0x52, 0x4f, 0x5f, 0x4c,
0x45, 0x4e, 0x47, 0x54, 0x48, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x48, 0x45, 0x43, 0x4b,
0x5f, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x01, 0x32, 0x7f, 0x0a, 0x0b, 0x54, 0x72, 0x61,
0x6e, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x06, 0x45, 0x6e, 0x63, 0x6f,
0x64, 0x65, 0x12, 0x15, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x2e, 0x45, 0x6e, 0x63, 0x6f,
0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x73, 0x69, 0x67, 0x6e,
0x65, 0x72, 0x2e, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x37, 0x0a, 0x06, 0x44, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x15, 0x2e, 0x73, 0x69,
0x67, 0x6e, 0x65, 0x72, 0x2e, 0x44, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x16, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x2e, 0x44, 0x65, 0x63, 0x6f,
0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x61, 0x70,
0x69, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_api_based32_proto_rawDescOnce sync.Once
file_api_based32_proto_rawDescData = file_api_based32_proto_rawDesc
)
func file_api_based32_proto_rawDescGZIP() []byte {
file_api_based32_proto_rawDescOnce.Do(func() {
file_api_based32_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_based32_proto_rawDescData)
})
return file_api_based32_proto_rawDescData
}
var file_api_based32_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_api_based32_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_api_based32_proto_goTypes = []interface{}{
(Error)(0), // 0: signer.Error
(*EncodeRequest)(nil), // 1: signer.EncodeRequest
(*EncodeResponse)(nil), // 2: signer.EncodeResponse
(*DecodeRequest)(nil), // 3: signer.DecodeRequest
(*DecodeResponse)(nil), // 4: signer.DecodeResponse
}
var file_api_based32_proto_depIdxs = []int32{
0, // 0: signer.EncodeResponse.Error:type_name -> signer.Error
0, // 1: signer.DecodeResponse.Error:type_name -> signer.Error
1, // 2: signer.Transcriber.Encode:input_type -> signer.EncodeRequest
3, // 3: signer.Transcriber.Decode:input_type -> signer.DecodeRequest
2, // 4: signer.Transcriber.Encode:output_type -> signer.EncodeResponse
4, // 5: signer.Transcriber.Decode:output_type -> signer.DecodeResponse
4, // [4:6] is the sub-list for method output_type
2, // [2:4] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_api_based32_proto_init() }
func file_api_based32_proto_init() {
if File_api_based32_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_api_based32_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EncodeRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_based32_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EncodeResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_based32_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DecodeRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_based32_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DecodeResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_api_based32_proto_msgTypes[1].OneofWrappers = []interface{}{
(*EncodeResponse_EncodedString)(nil),
(*EncodeResponse_Error)(nil),
}
file_api_based32_proto_msgTypes[3].OneofWrappers = []interface{}{
(*DecodeResponse_Data)(nil),
(*DecodeResponse_Error)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_api_based32_proto_rawDesc,
NumEnums: 1,
NumMessages: 4,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_api_based32_proto_goTypes,
DependencyIndexes: file_api_based32_proto_depIdxs,
EnumInfos: file_api_based32_proto_enumTypes,
MessageInfos: file_api_based32_proto_msgTypes,
}.Build()
File_api_based32_proto = out.File
file_api_based32_proto_rawDesc = nil
file_api_based32_proto_goTypes = nil
file_api_based32_proto_depIdxs = nil
}

View File

@@ -1,6 +1,6 @@
syntax = "proto3";
package signer;
option go_package = "github.com/quanterall/service";
option go_package = "api/";
service Transcriber {
rpc Encode(EncodeRequest) returns (EncodeResponse);

View File

@@ -1,4 +1,4 @@
package b32svc
package service
import (
logg "log"

View File

@@ -1,46 +1,6 @@
package b32svc
package service
type Service struct {
ServiceDefinition
incoming chan interface{}
quit chan struct{}
}
type Handler struct {
Chan interface{}
Params interface{}
Result interface{}
}
type Handlers map[string]Handler
type ServiceDefinition struct {
Name string
Handlers
}
func New(svc ServiceDefinition) *Service {
return &Service{ServiceDefinition: svc}
}
func (s *Service) Run() func() {
s.quit = make(chan struct{})
go func() {
out:
for {
select {
case msg := <-s.incoming:
switch msg := msg.(type) {
case int:
_ = msg
default:
}
case <-s.quit:
break out
}
}
log.Println(s.ServiceDefinition.Name, "service runner is now shut down")
}()
return func() { close(s.quit) }
}
// The following line generates the protocol, it assumes that `protoc` is in the
// path. This directive is run when `go generate` is run in the current package,
// or if a wildcard was used ( go generate ./... ).
//go:generate protoc -I=. --go_out=. ./api/based32.proto