github.com/lastbackend/toolkit@v0.0.0-20241020043710-cafa37b95aad/pkg/runtime/controller/client.go (about)

     1  package controller
     2  
     3  import (
     4  	"context"
     5  	"github.com/lastbackend/toolkit/pkg/client"
     6  	"github.com/lastbackend/toolkit/pkg/client/grpc"
     7  	"github.com/lastbackend/toolkit/pkg/runtime"
     8  	"github.com/lastbackend/toolkit/pkg/runtime/logger"
     9  )
    10  
    11  type clientManager struct {
    12  	log  logger.Logger
    13  	grpc client.GRPCClient
    14  	http client.HTTPClient
    15  }
    16  
    17  func (c *clientManager) GRPC() client.GRPCClient {
    18  	return c.grpc
    19  }
    20  
    21  func (c *clientManager) HTTP() client.HTTPClient {
    22  	return c.http
    23  }
    24  
    25  func newClientController(ctx context.Context, runtime runtime.Runtime) runtime.Client {
    26  	cl := new(clientManager)
    27  
    28  	cl.log = runtime.Log()
    29  	cl.grpc = grpc.NewClient(ctx, runtime)
    30  
    31  	return cl
    32  }