mirror of
https://github.com/ultravioletrs/cocos.git
synced 2026-08-07 07:14:50 +00:00
Refactor run request to use slice of bytes to represent computation
Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
This commit is contained in:
+32
-144
@@ -1,13 +1,15 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc-gen-go v1.25.0
|
||||
// protoc v3.12.4
|
||||
// source: proto/agent.proto
|
||||
|
||||
// import "google/protobuf/timestamp.proto";
|
||||
|
||||
package agent
|
||||
|
||||
import (
|
||||
timestamp "github.com/golang/protobuf/ptypes/timestamp"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
@@ -21,23 +23,16 @@ const (
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
||||
// of the legacy proto package is being used.
|
||||
const _ = proto.ProtoPackageIsVersion4
|
||||
|
||||
type RunRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
|
||||
Status string `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"`
|
||||
Owner string `protobuf:"bytes,5,opt,name=owner,proto3" json:"owner,omitempty"`
|
||||
StartTime *timestamp.Timestamp `protobuf:"bytes,6,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"`
|
||||
EndTime *timestamp.Timestamp `protobuf:"bytes,7,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"`
|
||||
Datasets []string `protobuf:"bytes,8,rep,name=datasets,proto3" json:"datasets,omitempty"`
|
||||
Algorithms []string `protobuf:"bytes,9,rep,name=algorithms,proto3" json:"algorithms,omitempty"`
|
||||
DatasetProviders []string `protobuf:"bytes,10,rep,name=dataset_providers,json=datasetProviders,proto3" json:"dataset_providers,omitempty"`
|
||||
AlgorithmProviders []string `protobuf:"bytes,11,rep,name=algorithm_providers,json=algorithmProviders,proto3" json:"algorithm_providers,omitempty"`
|
||||
ResultConsumers []string `protobuf:"bytes,13,rep,name=result_consumers,json=resultConsumers,proto3" json:"result_consumers,omitempty"`
|
||||
Ttl int32 `protobuf:"varint,12,opt,name=ttl,proto3" json:"ttl,omitempty"`
|
||||
Computation []byte `protobuf:"bytes,1,opt,name=computation,proto3" json:"computation,omitempty"`
|
||||
}
|
||||
|
||||
func (x *RunRequest) Reset() {
|
||||
@@ -72,90 +67,13 @@ func (*RunRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_agent_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *RunRequest) GetName() string {
|
||||
func (x *RunRequest) GetComputation() []byte {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RunRequest) GetDescription() string {
|
||||
if x != nil {
|
||||
return x.Description
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RunRequest) GetStatus() string {
|
||||
if x != nil {
|
||||
return x.Status
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RunRequest) GetOwner() string {
|
||||
if x != nil {
|
||||
return x.Owner
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RunRequest) GetStartTime() *timestamp.Timestamp {
|
||||
if x != nil {
|
||||
return x.StartTime
|
||||
return x.Computation
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *RunRequest) GetEndTime() *timestamp.Timestamp {
|
||||
if x != nil {
|
||||
return x.EndTime
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *RunRequest) GetDatasets() []string {
|
||||
if x != nil {
|
||||
return x.Datasets
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *RunRequest) GetAlgorithms() []string {
|
||||
if x != nil {
|
||||
return x.Algorithms
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *RunRequest) GetDatasetProviders() []string {
|
||||
if x != nil {
|
||||
return x.DatasetProviders
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *RunRequest) GetAlgorithmProviders() []string {
|
||||
if x != nil {
|
||||
return x.AlgorithmProviders
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *RunRequest) GetResultConsumers() []string {
|
||||
if x != nil {
|
||||
return x.ResultConsumers
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *RunRequest) GetTtl() int32 {
|
||||
if x != nil {
|
||||
return x.Ttl
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type RunResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -208,45 +126,18 @@ var File_proto_agent_proto protoreflect.FileDescriptor
|
||||
var file_proto_agent_proto_rawDesc = []byte{
|
||||
0x0a, 0x11, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x22, 0xb9, 0x03, 0x0a, 0x0a, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72,
|
||||
0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73,
|
||||
0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14,
|
||||
0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f,
|
||||
0x77, 0x6e, 0x65, 0x72, 0x12, 0x39, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73,
|
||||
0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12,
|
||||
0x35, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28,
|
||||
0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x07, 0x65,
|
||||
0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x73, 0x65,
|
||||
0x74, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x73, 0x65,
|
||||
0x74, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x6c, 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x73,
|
||||
0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x6c, 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68,
|
||||
0x6d, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x64, 0x61, 0x74, 0x61, 0x73, 0x65, 0x74, 0x5f, 0x70, 0x72,
|
||||
0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x64,
|
||||
0x61, 0x74, 0x61, 0x73, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x12,
|
||||
0x2f, 0x0a, 0x13, 0x61, 0x6c, 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x5f, 0x70, 0x72, 0x6f,
|
||||
0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x09, 0x52, 0x12, 0x61, 0x6c,
|
||||
0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73,
|
||||
0x12, 0x29, 0x0a, 0x10, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x75,
|
||||
0x6d, 0x65, 0x72, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x72, 0x65, 0x73, 0x75,
|
||||
0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74,
|
||||
0x74, 0x6c, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x74, 0x6c, 0x22, 0x2f, 0x0a,
|
||||
0x0b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x0b,
|
||||
0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x0b, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0x4a,
|
||||
0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3a,
|
||||
0x0a, 0x03, 0x52, 0x75, 0x6e, 0x12, 0x17, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18,
|
||||
0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x75, 0x6e,
|
||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f,
|
||||
0x61, 0x67, 0x65, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x22, 0x2e, 0x0a, 0x0a, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20,
|
||||
0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x0c, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x22, 0x2f, 0x0a, 0x0b, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
|
||||
0x20, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x32, 0x4a, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||
0x65, 0x12, 0x3a, 0x0a, 0x03, 0x52, 0x75, 0x6e, 0x12, 0x17, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74,
|
||||
0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x75, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x74, 0x1a, 0x18, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
|
||||
0x52, 0x75, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a,
|
||||
0x07, 0x2e, 0x2f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -263,20 +154,17 @@ func file_proto_agent_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_proto_agent_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_proto_agent_proto_goTypes = []interface{}{
|
||||
(*RunRequest)(nil), // 0: agent_proto.RunRequest
|
||||
(*RunResponse)(nil), // 1: agent_proto.RunResponse
|
||||
(*timestamp.Timestamp)(nil), // 2: google.protobuf.Timestamp
|
||||
(*RunRequest)(nil), // 0: agent_proto.RunRequest
|
||||
(*RunResponse)(nil), // 1: agent_proto.RunResponse
|
||||
}
|
||||
var file_proto_agent_proto_depIdxs = []int32{
|
||||
2, // 0: agent_proto.RunRequest.start_time:type_name -> google.protobuf.Timestamp
|
||||
2, // 1: agent_proto.RunRequest.end_time:type_name -> google.protobuf.Timestamp
|
||||
0, // 2: agent_proto.AgentService.Run:input_type -> agent_proto.RunRequest
|
||||
1, // 3: agent_proto.AgentService.Run:output_type -> agent_proto.RunResponse
|
||||
3, // [3:4] is the sub-list for method output_type
|
||||
2, // [2:3] 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
|
||||
0, // 0: agent_proto.AgentService.Run:input_type -> agent_proto.RunRequest
|
||||
1, // 1: agent_proto.AgentService.Run:output_type -> agent_proto.RunResponse
|
||||
1, // [1:2] is the sub-list for method output_type
|
||||
0, // [0:1] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_proto_agent_proto_init() }
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v3.12.4
|
||||
// source: proto/agent.proto
|
||||
|
||||
package agent
|
||||
|
||||
|
||||
@@ -44,17 +44,8 @@ func encodeRunRequest(_ context.Context, request interface{}) (interface{}, erro
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid request type: %T", request)
|
||||
}
|
||||
return &agent.RunRequest{
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
Owner: req.Owner,
|
||||
Datasets: req.Datasets,
|
||||
Algorithms: req.Algorithms,
|
||||
DatasetProviders: req.DatasetProviders,
|
||||
AlgorithmProviders: req.AlgorithmProviders,
|
||||
ResultConsumers: req.ResultConsumers,
|
||||
Ttl: req.TTL,
|
||||
}, nil
|
||||
|
||||
return &req, nil
|
||||
}
|
||||
|
||||
// decodeRunResponse is a transport/grpc.DecodeResponseFunc that
|
||||
@@ -69,23 +60,11 @@ func decodeRunResponse(_ context.Context, grpcResponse interface{}) (interface{}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (client grpcClient) Run(ctx context.Context, req *agent.RunRequest, _ ...grpc.CallOption) (*agent.RunResponse, error) {
|
||||
func (client grpcClient) Run(ctx context.Context, request *agent.RunRequest, _ ...grpc.CallOption) (*agent.RunResponse, error) {
|
||||
ctx, close := context.WithTimeout(ctx, client.timeout)
|
||||
defer close()
|
||||
|
||||
runReq := runReq{
|
||||
Name: req.GetName(),
|
||||
Description: req.GetDescription(),
|
||||
Owner: req.GetOwner(),
|
||||
Datasets: req.GetDatasets(),
|
||||
Algorithms: req.GetAlgorithms(),
|
||||
DatasetProviders: req.GetDatasetProviders(),
|
||||
AlgorithmProviders: req.GetAlgorithmProviders(),
|
||||
ResultConsumers: req.GetResultConsumers(),
|
||||
TTL: req.GetTtl(),
|
||||
}
|
||||
|
||||
res, err := client.run(ctx, runReq)
|
||||
res, err := client.run(ctx, request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -15,19 +15,7 @@ func runEndpoint(svc agent.Service) endpoint.Endpoint {
|
||||
return runRes{}, err
|
||||
}
|
||||
|
||||
comp := agent.Computation{
|
||||
Name: req.Name,
|
||||
Description: req.Description,
|
||||
Owner: req.Owner,
|
||||
Datasets: req.Datasets,
|
||||
Algorithms: req.Algorithms,
|
||||
DatasetProviders: req.DatasetProviders,
|
||||
AlgorithmProviders: req.AlgorithmProviders,
|
||||
ResultConsumers: req.ResultConsumers,
|
||||
Ttl: req.TTL,
|
||||
}
|
||||
|
||||
computation, err := svc.Run(context.TODO(), comp)
|
||||
computation, err := svc.Run(context.TODO(), req.computation)
|
||||
if err != nil {
|
||||
return runRes{}, err
|
||||
}
|
||||
|
||||
@@ -7,32 +7,9 @@ import (
|
||||
// type healthReq struct{}
|
||||
|
||||
type runReq struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
|
||||
Owner string `protobuf:"bytes,3,opt,name=owner,proto3" json:"owner,omitempty"`
|
||||
Datasets []string `protobuf:"bytes,4,rep,name=datasets,proto3" json:"datasets,omitempty"`
|
||||
Algorithms []string `protobuf:"bytes,5,rep,name=algorithms,proto3" json:"algorithms,omitempty"`
|
||||
DatasetProviders []string `protobuf:"bytes,6,rep,name=dataset_providers,json=datasetProviders,proto3" json:"dataset_providers,omitempty"`
|
||||
AlgorithmProviders []string `protobuf:"bytes,7,rep,name=algorithm_providers,json=algorithmProviders,proto3" json:"algorithm_providers,omitempty"`
|
||||
ResultConsumers []string `protobuf:"bytes,8,rep,name=result_consumers,json=resultConsumers,proto3" json:"result_consumers,omitempty"`
|
||||
TTL int32 `protobuf:"varint,9,opt,name=ttl,proto3" json:"ttl,omitempty"`
|
||||
computation agent.Computation
|
||||
}
|
||||
|
||||
func (req runReq) validate() error {
|
||||
if req.Name == "" {
|
||||
return agent.ErrMalformedEntity
|
||||
}
|
||||
if req.Owner == "" {
|
||||
return agent.ErrMalformedEntity
|
||||
}
|
||||
if len(req.Datasets) == 0 {
|
||||
return agent.ErrMalformedEntity
|
||||
}
|
||||
if len(req.Algorithms) == 0 {
|
||||
return agent.ErrMalformedEntity
|
||||
}
|
||||
if req.TTL <= 0 {
|
||||
return agent.ErrMalformedEntity
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
kitot "github.com/go-kit/kit/tracing/opentracing"
|
||||
kitgrpc "github.com/go-kit/kit/transport/grpc"
|
||||
@@ -27,16 +28,15 @@ func NewServer(tracer opentracing.Tracer, svc agent.Service) agent.AgentServiceS
|
||||
|
||||
func decodeRunRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
req := grpcReq.(*agent.RunRequest)
|
||||
|
||||
var computation agent.Computation
|
||||
err := json.Unmarshal(req.Computation, &computation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return runReq{
|
||||
Name: req.GetName(),
|
||||
Description: req.GetDescription(),
|
||||
Owner: req.GetOwner(),
|
||||
Datasets: req.GetDatasets(),
|
||||
Algorithms: req.GetAlgorithms(),
|
||||
DatasetProviders: req.GetDatasetProviders(),
|
||||
AlgorithmProviders: req.GetAlgorithmProviders(),
|
||||
ResultConsumers: req.GetResultConsumers(),
|
||||
TTL: req.GetTtl(),
|
||||
computation: computation,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package agent
|
||||
|
||||
import "time"
|
||||
|
||||
type Computation struct {
|
||||
ID string `json:"id,omitempty" db:"id"`
|
||||
Name string `json:"name,omitempty" db:"name"`
|
||||
Description string `json:"description,omitempty" db:"description"`
|
||||
Status string `json:"status,omitempty" db:"status"`
|
||||
Owner string `json:"owner,omitempty" db:"owner"`
|
||||
StartTime time.Time `json:"start_time,omitempty" db:"start_time"`
|
||||
EndTime time.Time `json:"end_time,omitempty" db:"end_time"`
|
||||
Datasets []string `json:"datasets,omitempty" db:"datasets"`
|
||||
Algorithms []string `json:"algorithms,omitempty" db:"algorithms"`
|
||||
DatasetProviders []string `json:"dataset_providers,omitempty" db:"dataset_providers"`
|
||||
AlgorithmProviders []string `json:"algorithm_providers,omitempty" db:"algorithm_providers"`
|
||||
ResultConsumers []string `json:"result_consumers,omitempty" db:"result_consumers"`
|
||||
Ttl int32 `json:"ttl,omitempty" db:"ttl"`
|
||||
Metadata Metadata `json:"metadata,omitempty" db:"metadata"`
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -21,23 +20,6 @@ var (
|
||||
ErrUnauthorizedAccess = errors.New("missing or invalid credentials provided")
|
||||
)
|
||||
|
||||
type Computation struct {
|
||||
ID string `json:"id,omitempty" db:"id"`
|
||||
Name string `json:"name,omitempty" db:"name"`
|
||||
Description string `json:"description,omitempty" db:"description"`
|
||||
Status string `json:"status,omitempty" db:"status"`
|
||||
Owner string `json:"owner,omitempty" db:"owner"`
|
||||
StartTime time.Time `json:"start_time,omitempty" db:"start_time"`
|
||||
EndTime time.Time `json:"end_time,omitempty" db:"end_time"`
|
||||
Datasets []string `json:"datasets,omitempty" db:"datasets"`
|
||||
Algorithms []string `json:"algorithms,omitempty" db:"algorithms"`
|
||||
DatasetProviders []string `json:"dataset_providers,omitempty" db:"dataset_providers"`
|
||||
AlgorithmProviders []string `json:"algorithm_providers,omitempty" db:"algorithm_providers"`
|
||||
ResultConsumers []string `json:"result_consumers,omitempty" db:"result_consumers"`
|
||||
Ttl int32 `json:"ttl,omitempty" db:"ttl"`
|
||||
Metadata Metadata `json:"metadata,omitempty" db:"metadata"`
|
||||
}
|
||||
|
||||
type Metadata map[string]interface{}
|
||||
|
||||
// Service specifies an API that must be fullfiled by the domain service
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module github.com/ultravioletrs/agent
|
||||
|
||||
go 1.19
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/go-kit/kit v0.12.0
|
||||
|
||||
+2
-15
@@ -1,6 +1,6 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
// import "google/protobuf/timestamp.proto";
|
||||
|
||||
package agent_proto;
|
||||
|
||||
@@ -14,19 +14,6 @@ service AgentService {
|
||||
// message HealthRequest {}
|
||||
// message HealthResponse { string status = 1; }
|
||||
|
||||
message RunRequest {
|
||||
string name = 2;
|
||||
string description = 3;
|
||||
string status = 4;
|
||||
string owner = 5;
|
||||
google.protobuf.Timestamp start_time = 6;
|
||||
google.protobuf.Timestamp end_time = 7;
|
||||
repeated string datasets = 8;
|
||||
repeated string algorithms = 9;
|
||||
repeated string dataset_providers = 10;
|
||||
repeated string algorithm_providers = 11;
|
||||
repeated string result_consumers = 13;
|
||||
int32 ttl = 12;
|
||||
}
|
||||
message RunRequest { bytes computation = 1; }
|
||||
|
||||
message RunResponse { string Computation = 1; }
|
||||
|
||||
Reference in New Issue
Block a user