Skip to content

gRPCのサーバを接続 / 設定情報をenumで定義 #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 10, 2023
Prev Previous commit
Next Next commit
feat: gRPCの呼び出しに、設定情報を反映する
  • Loading branch information
mochi-yu committed Sep 10, 2023
commit 91ded33f44d963b8d602324a559ee7d72d2efba2
16 changes: 10 additions & 6 deletions internal/gateway/grpc_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package gateway
import (
"context"
"crypto/tls"
"fmt"
"log"
"os"

"github.com/cocoide/commitify/internal/entity"
"github.com/cocoide/commitify/internal/service"
pb "github.com/cocoide/commitify/pkg/grpc"
"google.golang.org/grpc"
Expand Down Expand Up @@ -40,10 +42,12 @@ func NewGrpcServeGateway() *grpcServeGateway {
}

func (gsg grpcServeGateway) FetchCommitMessages() ([]string, error) {
// 設定情報からOpenAIへのアクセス方法の変更
// if conf, err := entity.ReadConfig(); err != nil {
// fmt.Printf("設定ファイルが開けません: %v", err)
// }
// 設定情報を取得
conf, err := entity.ReadConfig()
if err != nil {
fmt.Printf("設定ファイルが開けません: %v", err)
}
cft, lt := conf.Config2PbVars()

fds := service.NewFileDiffService()

Expand All @@ -55,8 +59,8 @@ func (gsg grpcServeGateway) FetchCommitMessages() ([]string, error) {

req := &pb.CommitMessageRequest{
InputCode: diffStr,
CodeFormat: pb.CodeFormatType_PREFIX,
Language: pb.LanguageType_ENGLISH,
CodeFormat: cft,
Language: lt,
}

res, err := gsg.client.GenerateCommitMessage(context.Background(), req)
Expand Down