Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Add gRPC-support #3

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
FROM golang:1.23-alpine AS deps
COPY go.mod go.sum ./
RUN go mod download

FROM golang:1.23-alpine AS golang-with-curl
RUN apk --no-cache add curl

FROM golang-with-curl
WORKDIR /app
COPY --from=deps /go/pkg/mod /go/pkg/mod
COPY go.mod .
COPY go.sum .
COPY common common

ARG DAY
Expand Down
26 changes: 26 additions & 0 deletions common/env/env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package env

import "os"

const (
HttpPrefix = "AOC2024_HTTP_PREFIX"
HttpPort = "AOC2024_HTTP_PORT"
GrpcPort = "AOC2024_GRPC_PORT"
)

func GetString(
key string,
) string {
return os.Getenv(key)
}

func GetStringOrDefault(
key string,
def string,
) string {
v := os.Getenv(key)
if v == "" {
return def
}
return v
}
192 changes: 192 additions & 0 deletions common/proto/adventservice.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions common/proto/adventservice.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";
package adventservice;

option go_package = "github.com/terminalnode/adventofcode2024/common/proto";


service AdventService {
rpc SolvePart1 (InputData) returns (InputResponse);
rpc SolvePart2 (InputData) returns (InputResponse);
}

message InputData {
string input = 1;
}

message InputResponse {
string result = 1;
}
Loading
Loading