mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
Adding max-inbound-message-size startup parameter (#2746)
so we can download large DARs to collect TemplateIDs for the future TemplateID resolution.
This commit is contained in:
parent
99e765a1e0
commit
4036b4ae2e
@ -10,11 +10,12 @@ daml-head sandbox --wall-clock-time --ledgerid MyLedger ./.daml/dist/quickstart-
|
||||
### Start HTTP service from the DAML project root
|
||||
This will build the service first, can take up to 5-10 minutes when running first time.
|
||||
```
|
||||
$ bazel run //ledger-service/http-json:http-json-binary -- localhost 6865 7575
|
||||
$ bazel run //ledger-service/http-json:http-json-binary -- localhost 6865 7575 4194304
|
||||
```
|
||||
Where:
|
||||
- localhost 6865 -- sandbox host and port
|
||||
- 7575 -- HTTP service port
|
||||
- 4194304 -- max inbound message size in bytes (the max size of the message received from the ledger). To set the same limit on the sandbox side, use ` --maxInboundMessageSize` command line parameter.
|
||||
|
||||
## Example session
|
||||
|
||||
|
@ -39,6 +39,8 @@ import scala.{util => u}
|
||||
|
||||
object HttpService extends StrictLogging {
|
||||
|
||||
val DefaultMaxInboundMessageSize: Int = 4194304
|
||||
|
||||
private type ET[A] = EitherT[Future, Error, A]
|
||||
|
||||
final case class Error(message: String)
|
||||
@ -48,6 +50,7 @@ object HttpService extends StrictLogging {
|
||||
ledgerPort: Int,
|
||||
applicationId: ApplicationId,
|
||||
httpPort: Int,
|
||||
maxInboundMessageSize: Int = DefaultMaxInboundMessageSize,
|
||||
validateJwt: Endpoints.ValidateJwt = decodeJwt)(
|
||||
implicit asys: ActorSystem,
|
||||
mat: Materializer,
|
||||
@ -64,7 +67,8 @@ object HttpService extends StrictLogging {
|
||||
|
||||
val bindingEt: EitherT[Future, Error, ServerBinding] = for {
|
||||
clientChannel <- FutureUtil
|
||||
.either(LedgerClientJwt.singleHostChannel(ledgerHost, ledgerPort, clientConfig)(ec, aesf))
|
||||
.either(LedgerClientJwt
|
||||
.singleHostChannel(ledgerHost, ledgerPort, clientConfig, maxInboundMessageSize)(ec, aesf))
|
||||
.leftMap(e => Error(e.getMessage)): ET[io.grpc.Channel]
|
||||
|
||||
client <- FutureUtil
|
||||
|
@ -31,12 +31,17 @@ object LedgerClientJwt {
|
||||
type GetActiveContracts =
|
||||
(Jwt, TransactionFilter, Boolean) => Source[GetActiveContractsResponse, Future[String]]
|
||||
|
||||
def singleHostChannel(hostIp: String, port: Int, configuration: LedgerClientConfiguration)(
|
||||
def singleHostChannel(
|
||||
hostIp: String,
|
||||
port: Int,
|
||||
configuration: LedgerClientConfiguration,
|
||||
maxInboundMessageSize: Int)(
|
||||
implicit ec: ExecutionContext,
|
||||
esf: ExecutionSequencerFactory): Throwable \/ Channel = \/.fromTryCatchNonFatal {
|
||||
|
||||
val builder: NettyChannelBuilder = NettyChannelBuilder
|
||||
.forAddress(hostIp, port)
|
||||
.maxInboundMessageSize(maxInboundMessageSize)
|
||||
|
||||
configuration.sslContext
|
||||
.fold {
|
||||
|
@ -8,6 +8,7 @@ import akka.http.scaladsl.Http.ServerBinding
|
||||
import akka.stream.ActorMaterializer
|
||||
import com.digitalasset.grpc.adapter.{AkkaExecutionSequencerPool, ExecutionSequencerFactory}
|
||||
import com.digitalasset.ledger.api.refinements.ApiTypes.ApplicationId
|
||||
|
||||
import com.typesafe.scalalogging.StrictLogging
|
||||
import scalaz.\/
|
||||
|
||||
@ -24,12 +25,15 @@ object Main extends StrictLogging {
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
|
||||
if (args.length != 3)
|
||||
if (args.length != 3 && args.length != 4)
|
||||
reportInvalidUsageAndExit()
|
||||
|
||||
val ledgerHost: String = args(0)
|
||||
val ledgerPort: Int = Try(args(1).toInt).fold(e => reportInvalidUsageAndExit(e), identity)
|
||||
val httpPort: Int = Try(args(2).toInt).fold(e => reportInvalidUsageAndExit(e), identity)
|
||||
val maxInboundMessageSize: Int =
|
||||
if (args.length >= 4) Try(args(3).toInt).fold(e => reportInvalidUsageAndExit(e), identity)
|
||||
else HttpService.DefaultMaxInboundMessageSize
|
||||
|
||||
logger.info(s"ledgerHost: $ledgerHost, ledgerPort: $ledgerPort, httpPort: $httpPort")
|
||||
|
||||
@ -42,7 +46,7 @@ object Main extends StrictLogging {
|
||||
val applicationId = ApplicationId("HTTP-JSON-API-Gateway")
|
||||
|
||||
val serviceF: Future[HttpService.Error \/ ServerBinding] =
|
||||
HttpService.start(ledgerHost, ledgerPort, applicationId, httpPort)
|
||||
HttpService.start(ledgerHost, ledgerPort, applicationId, httpPort, maxInboundMessageSize)
|
||||
|
||||
sys.addShutdownHook {
|
||||
HttpService
|
||||
@ -72,7 +76,8 @@ object Main extends StrictLogging {
|
||||
* Report usage and exit the program. Guaranteed by type not to terminate.
|
||||
*/
|
||||
private def reportInvalidUsageAndExit(): Nothing = {
|
||||
logger.error("Usage: LEDGER_HOST LEDGER_PORT HTTP_PORT")
|
||||
logger.error(
|
||||
"Usage: <ledger-host> <ledger-port> <http-port> [<max-inbound-message-size-in-bytes>]")
|
||||
sys.exit(ErrorCodes.InvalidUsage)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user