feat:#36 added protobuf communication for modules

This commit is contained in:
Elmar Kresse
2024-06-17 00:59:33 +02:00
parent 8548a537ec
commit fad85f2884
18 changed files with 1286 additions and 59 deletions

View File

@@ -0,0 +1,13 @@
package model
import (
"github.com/gofiber/fiber/v3"
googleGRPC "google.golang.org/grpc"
)
type AppType struct {
GrpcClient *googleGRPC.ClientConn
Host string
Fiber *fiber.App
DataManagerURL string
}

View File

@@ -19,10 +19,14 @@ package model
import (
"encoding/json"
"fmt"
"log/slog"
"strings"
"time"
)
// DefaultDateLayout specifies the default app date strings layout.
const DefaultDateLayout = "2006-01-02 15:04:05.000Z"
// IcalModel local type for EmitICal function
type IcalModel struct {
Events Events
@@ -73,10 +77,19 @@ func (jt *JSONTime) UnmarshalJSON(b []byte) error {
if timeString == "null" || timeString == "" {
return nil
}
t, err := time.Parse("2006-01-02 15:04:05.000Z", timeString)
t, err := time.Parse(DefaultDateLayout, timeString)
if err == nil {
*jt = JSONTime(t)
return nil
}
return fmt.Errorf("error parsing time string %s: %w", timeString, err)
}
func ToJSONTime(timeString string) JSONTime {
t, err := time.Parse(DefaultDateLayout, timeString)
if err != nil {
slog.Error("error parsing time string: ", "error", err)
return JSONTime(time.Time{})
}
return JSONTime(t)
}