package main import ( "context" "fmt" "log" "logger/data" "time" ) type RPCServer struct{} type RPCPayload struct { Name string Data string } func (r *RPCServer) LogInfo(payload RPCPayload, resp *string) error { collection := client.Database("logs").Collection("logs") now := time.Now() payload.Data += fmt.Sprintf(" received date %d", now.UnixMicro()) _, err := collection.InsertOne(context.TODO(), data.LogEntry{ Name: payload.Name, Data: payload.Data, CreatedAt: time.Now(), }) if err != nil { log.Println("error writing to mongo", err) return err } *resp = "Processed payload via RPC:" + payload.Name return nil }