generated from rmcguire/go-server-with-otel
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
7e78b271f4 | |||
d5abda89a1 | |||
02dc08fb1e | |||
ac8d62a98e |
@ -17,11 +17,11 @@ RUN go build -C . -v -ldflags "-extldflags '-static' -X ${VER_PKG}=${VERSION}" -
|
|||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
ARG APP_NAME=demo-app
|
ARG APP_NAME=class-server
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
USER 100:101
|
USER 100:101
|
||||||
|
|
||||||
COPY --from=build --chown=100:101 /app/${APP_NAME} /app/
|
COPY --from=build --chown=100:101 /app/${APP_NAME} /app/app
|
||||||
|
|
||||||
ENTRYPOINT [ "/app/${APP_NAME}" ]
|
ENTRYPOINT [ "/app/app" ]
|
||||||
|
@ -15,13 +15,13 @@ type: application
|
|||||||
# This is the chart version. This version number should be incremented each time you make changes
|
# This is the chart version. This version number should be incremented each time you make changes
|
||||||
# to the chart and its templates, including the app version.
|
# to the chart and its templates, including the app version.
|
||||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||||
version: 0.1.3
|
version: 0.1.4
|
||||||
|
|
||||||
# This is the version number of the application being deployed. This version number should be
|
# This is the version number of the application being deployed. This version number should be
|
||||||
# incremented each time you make changes to the application. Versions are not expected to
|
# incremented each time you make changes to the application. Versions are not expected to
|
||||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||||
# It is recommended to use it with quotes.
|
# It is recommended to use it with quotes.
|
||||||
appVersion: "v0.1.1"
|
appVersion: "v0.2.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- name: hull
|
- name: hull
|
||||||
|
7
main.go
7
main.go
@ -23,6 +23,7 @@ import (
|
|||||||
optsgrpc "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/grpc/opts"
|
optsgrpc "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/grpc/opts"
|
||||||
optshttp "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/http/opts"
|
optshttp "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/http/opts"
|
||||||
|
|
||||||
|
class "gitea.libretechconsulting.com/rmcguire/class-server/api/class/v1alpha1"
|
||||||
"gitea.libretechconsulting.com/rmcguire/class-server/pkg/classgrpc"
|
"gitea.libretechconsulting.com/rmcguire/class-server/pkg/classgrpc"
|
||||||
"gitea.libretechconsulting.com/rmcguire/class-server/pkg/config"
|
"gitea.libretechconsulting.com/rmcguire/class-server/pkg/config"
|
||||||
"gitea.libretechconsulting.com/rmcguire/class-server/pkg/demogrpc"
|
"gitea.libretechconsulting.com/rmcguire/class-server/pkg/demogrpc"
|
||||||
@ -52,7 +53,11 @@ func main() {
|
|||||||
demoHTTP := demohttp.NewDemoHTTPServer(ctx, demoApp)
|
demoHTTP := demohttp.NewDemoHTTPServer(ctx, demoApp)
|
||||||
demoGRPC := demogrpc.NewDemoGRPCServer(ctx, demoApp)
|
demoGRPC := demogrpc.NewDemoGRPCServer(ctx, demoApp)
|
||||||
|
|
||||||
classGRPC := classgrpc.New(ctx)
|
classGRPC := classgrpc.New(&classgrpc.ClassServiceOpts{
|
||||||
|
Ctx: ctx,
|
||||||
|
Font: class.Font_FONT_AVATAR,
|
||||||
|
Text: "Indiana Tech Net 1500",
|
||||||
|
})
|
||||||
|
|
||||||
// Prepare app
|
// Prepare app
|
||||||
app := &app.App{
|
app := &app.App{
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// Package classgrpc provides demonstrative rpc implementation for class server
|
||||||
|
// TODO: Move font and text to ClassServiceOpts in New() and use
|
||||||
package classgrpc
|
package classgrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -12,16 +14,24 @@ import (
|
|||||||
type ClassService struct {
|
type ClassService struct {
|
||||||
class.UnimplementedClassServiceServer
|
class.UnimplementedClassServiceServer
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
font class.Font
|
||||||
|
text string
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClassServiceOpts struct {
|
||||||
|
Ctx context.Context
|
||||||
|
Font class.Font
|
||||||
|
Text string
|
||||||
}
|
}
|
||||||
|
|
||||||
var DefaultFont = class.Font_FONT_BARBWIRE
|
var DefaultFont = class.Font_FONT_BARBWIRE
|
||||||
|
|
||||||
func (s *ClassService) GetClassLogo(ctx context.Context, req *class.GetClassLogoRequest) (*class.GetClassLogoResponse, error) {
|
func (s *ClassService) GetClassLogo(ctx context.Context, req *class.GetClassLogoRequest) (*class.GetClassLogoResponse, error) {
|
||||||
if req.GetFont() == class.Font_FONT_UNSPECIFIED {
|
if req.GetFont() == class.Font_FONT_UNSPECIFIED {
|
||||||
req.Font = DefaultFont
|
req.Font = s.font
|
||||||
}
|
}
|
||||||
|
|
||||||
f := figure.NewFigure("Indiana Tech", getFontString(req.GetFont()), false)
|
f := figure.NewFigure(s.text, getFontString(req.GetFont()), false)
|
||||||
|
|
||||||
resp := &class.GetClassLogoResponse{
|
resp := &class.GetClassLogoResponse{
|
||||||
LogoBytes: []byte(f.String()),
|
LogoBytes: []byte(f.String()),
|
||||||
@ -38,8 +48,10 @@ func getFontString(font class.Font) string {
|
|||||||
return strings.ToLower(strings.ReplaceAll(font.String(), "FONT_", ""))
|
return strings.ToLower(strings.ReplaceAll(font.String(), "FONT_", ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(ctx context.Context) *ClassService {
|
func New(opts *ClassServiceOpts) *ClassService {
|
||||||
return &ClassService{
|
return &ClassService{
|
||||||
ctx: ctx,
|
ctx: opts.Ctx,
|
||||||
|
font: opts.Font,
|
||||||
|
text: opts.Text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user