diff --git a/internal/schema/module.go b/internal/schema/module.go index 35a49e53c2..405f10bc59 100644 --- a/internal/schema/module.go +++ b/internal/schema/module.go @@ -14,6 +14,7 @@ import ( "github.com/alecthomas/types/optional" "golang.org/x/exp/maps" "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/timestamppb" schemapb "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/schema" ) @@ -218,12 +219,27 @@ func (m *Module) Imports() []string { } func (m *Module) ToProto() proto.Message { + var runtime *schemapb.ModuleRuntime + if m.Runtime != nil { + runtime = &schemapb.ModuleRuntime{ + CreateTime: timestamppb.New(m.Runtime.CreateTime), + Language: m.Runtime.Language, + MinReplicas: m.Runtime.MinReplicas, + } + if m.Runtime.OS != "" { + runtime.Os = &m.Runtime.OS + } + if m.Runtime.Arch != "" { + runtime.Arch = &m.Runtime.Arch + } + } return &schemapb.Module{ Pos: posToProto(m.Pos), Builtin: m.Builtin, Name: m.Name, Comments: m.Comments, Decls: declListToProto(m.Decls), + Runtime: runtime, } } @@ -248,6 +264,15 @@ func ModuleFromProto(s *schemapb.Module) (*Module, error) { Comments: s.Comments, Decls: declListToSchema(s.Decls), } + if s.Runtime != nil { + module.Runtime = &ModuleRuntime{ + CreateTime: s.Runtime.GetCreateTime().AsTime(), + Language: s.Runtime.Language, + MinReplicas: s.Runtime.MinReplicas, + OS: s.Runtime.GetOs(), + Arch: s.Runtime.GetArch(), + } + } return module, ValidateModule(module) } diff --git a/internal/schema/verb.go b/internal/schema/verb.go index 2409eb2c02..c5392ca003 100644 --- a/internal/schema/verb.go +++ b/internal/schema/verb.go @@ -7,6 +7,7 @@ import ( "github.com/alecthomas/types/optional" "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/timestamppb" schemapb "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/schema" "github.com/TBD54566975/ftl/internal/slices" @@ -152,6 +153,14 @@ func (v *Verb) GetMetadataCronJob() optional.Option[*MetadataCronJob] { } func (v *Verb) ToProto() proto.Message { + var runtime *schemapb.VerbRuntime + if v.Runtime != nil { + runtime = &schemapb.VerbRuntime{ + CreateTime: timestamppb.New(v.Runtime.CreateTime), + StartTime: timestamppb.New(v.Runtime.StartTime), + Status: schemapb.VerbStatus(v.Runtime.Status), + } + } return &schemapb.Verb{ Pos: posToProto(v.Pos), Export: v.Export, @@ -160,10 +169,19 @@ func (v *Verb) ToProto() proto.Message { Request: TypeToProto(v.Request), Response: TypeToProto(v.Response), Metadata: metadataListToProto(v.Metadata), + Runtime: runtime, } } func VerbFromProto(s *schemapb.Verb) *Verb { + var runtime *VerbRuntime + if s.Runtime != nil { + runtime = &VerbRuntime{ + CreateTime: s.Runtime.CreateTime.AsTime(), + StartTime: s.Runtime.StartTime.AsTime(), + Status: VerbStatus(s.Runtime.Status), + } + } return &Verb{ Pos: PosFromProto(s.Pos), Export: s.Export, @@ -172,5 +190,6 @@ func VerbFromProto(s *schemapb.Verb) *Verb { Request: TypeFromProto(s.Request), Response: TypeFromProto(s.Response), Metadata: metadataListToSchema(s.Metadata), + Runtime: runtime, } }