Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
Open
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
12 changes: 6 additions & 6 deletions service/servers/oracle/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ func (os *OracleServer) routeRequest(w http.ResponseWriter, r *http.Request) {
// StartServerWithListener starts the oracle gRPC server with a given listener. The server is killed on any errors from the listener, or if ctx is cancelled.
// This method returns an error via any failure from the listener. This is a blocking call, i.e. until the server is closed or the server errors,
// this method will block.
func (os *OracleServer) StartServerWithListener(ctx context.Context, ln net.Listener) error {
func (os *OracleServer) StartServerWithListener(ctx context.Context, ln net.Listener, opts ...grpc.ServerOption) error {
os.httpSrv = &http.Server{
ReadHeaderTimeout: DefaultServerShutdownTimeout,
}
// create grpc server
os.grpcSrv = grpc.NewServer()
os.grpcSrv = grpc.NewServer(opts...)
// register oracle server
types.RegisterOracleServer(os.grpcSrv, os)

Expand All @@ -102,8 +102,8 @@ func (os *OracleServer) StartServerWithListener(ctx context.Context, ln net.List
OrigName: true,
}),
)
opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithNoProxy()}
err := types.RegisterOracleHandlerFromEndpoint(ctx, os.gatewayMux, ln.Addr().String(), opts)
dialOpts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithNoProxy()}
err := types.RegisterOracleHandlerFromEndpoint(ctx, os.gatewayMux, ln.Addr().String(), dialOpts)
if err != nil {
return err
}
Expand Down Expand Up @@ -152,13 +152,13 @@ func (os *OracleServer) StartServerWithListener(ctx context.Context, ln net.List
// StartServer starts the oracle gRPC server on the given host and port. The server is killed on any errors from the listener, or if ctx is cancelled.
// This method returns an error via any failure from the listener. This is a blocking call, i.e. until the server is closed or the server errors,
// this method will block.
func (os *OracleServer) StartServer(ctx context.Context, host, port string) error {
func (os *OracleServer) StartServer(ctx context.Context, host, port string, opts ...grpc.ServerOption) error {
addr := fmt.Sprintf("%s:%s", host, port)
ln, err := net.Listen("tcp", addr)
if err != nil {
return err
}
return os.StartServerWithListener(ctx, ln)
return os.StartServerWithListener(ctx, ln, opts...)
}

// Prices calls the underlying oracle's implementation of GetPrices. It defers to the ctx in the request, and errors if the context is cancelled
Expand Down