implement reference grpc server

This commit is contained in:
2025-03-30 20:19:25 -04:00
parent 4bd50b75b9
commit a69cd3f44c
14 changed files with 202 additions and 27 deletions

25
pkg/demogrpc/fact.go Normal file
View File

@ -0,0 +1,25 @@
package demogrpc
import (
"google.golang.org/protobuf/types/known/timestamppb"
pb "gitea.libretechconsulting.com/rmcguire/go-http-server-with-otel/api/demo/app/v1alpha1"
)
type RandomFact struct {
ID string `json:"id,omitempty"`
Text string `json:"text,omitempty"`
Source string `json:"source,omitempty"`
SourceURL string `json:"source_url,omitempty"`
Language string `json:"language,omitempty"`
Permalink string `json:"permalink,omitempty"`
}
func (f *RandomFact) FactToProto() *pb.GetDemoResponse {
return &pb.GetDemoResponse{
Timestamp: timestamppb.Now(),
Fact: f.Text,
Source: f.SourceURL,
Language: f.Language,
}
}