Skip to content

Commit

Permalink
Merge branch 'main' into feat/verify-ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath authored Sep 29, 2024
2 parents 49b3678 + a302df1 commit d67c449
Show file tree
Hide file tree
Showing 44 changed files with 459 additions and 310 deletions.
94 changes: 47 additions & 47 deletions Cargo.lock

Large diffs are not rendered by default.

56 changes: 49 additions & 7 deletions generated/.tailcallrc.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ directive @cache(
Provides the ability to refer to multiple fields in the Query or Mutation root.
"""
directive @call(
"""
Enables deduplication of IO operations to enhance performance.This flag prevents
duplicate IO requests from being executed concurrently, reducing resource load. Caution:
May lead to issues with APIs that expect unique results for identical inputs, such
as nonce-based APIs.
"""
dedupe: Boolean
"""
Steps are composed together to form a call. If you have multiple steps, the output
of the previous step is passed as input to the next step.
Expand Down Expand Up @@ -71,6 +78,13 @@ directive @graphQL(
"""
batch: Boolean!
"""
Enables deduplication of IO operations to enhance performance.This flag prevents
duplicate IO requests from being executed concurrently, reducing resource load. Caution:
May lead to issues with APIs that expect unique results for identical inputs, such
as nonce-based APIs.
"""
dedupe: Boolean
"""
The headers parameter allows you to customize the headers of the GraphQL request
made by the `@graphQL` operator. It is used by specifying a key-value map of header
names and their values.
Expand Down Expand Up @@ -111,6 +125,13 @@ directive @grpc(
"""
body: JSON
"""
Enables deduplication of IO operations to enhance performance.This flag prevents
duplicate IO requests from being executed concurrently, reducing resource load. Caution:
May lead to issues with APIs that expect unique results for identical inputs, such
as nonce-based APIs.
"""
dedupe: Boolean
"""
The `headers` parameter allows you to customize the headers of the HTTP request made
by the `@grpc` operator. It is used by specifying a key-value map of header names
and their values. Note: content-type is automatically set to application/grpc
Expand Down Expand Up @@ -148,6 +169,13 @@ directive @http(
"""
body: String
"""
Enables deduplication of IO operations to enhance performance.This flag prevents
duplicate IO requests from being executed concurrently, reducing resource load. Caution:
May lead to issues with APIs that expect unique results for identical inputs, such
as nonce-based APIs.
"""
dedupe: Boolean
"""
The `encoding` parameter specifies the encoding of the request body. It can be `ApplicationJson`
or `ApplicationXWwwFormUrlEncoded`. @default `ApplicationJson`.
"""
Expand Down Expand Up @@ -253,13 +281,6 @@ directive @server(
introducing latency and complicating debugging. Use judiciously. @default `false`.
"""
batchRequests: Boolean
"""
Enables deduplication of IO operations to enhance performance.This flag prevents
duplicate IO requests from being executed concurrently, reducing resource load. Caution:
May lead to issues with APIs that expect unique results for identical inputs, such
as nonce-based APIs.
"""
dedupe: Boolean
enableJIT: Boolean
"""
`globalResponseTimeout` sets the maximum query duration before termination, acting
Expand Down Expand Up @@ -747,6 +768,13 @@ input GraphQL {
"""
batch: Boolean!
"""
Enables deduplication of IO operations to enhance performance.This flag prevents
duplicate IO requests from being executed concurrently, reducing resource load. Caution:
May lead to issues with APIs that expect unique results for identical inputs, such
as nonce-based APIs.
"""
dedupe: Boolean
"""
The headers parameter allows you to customize the headers of the GraphQL request
made by the `@graphQL` operator. It is used by specifying a key-value map of header
names and their values.
Expand Down Expand Up @@ -787,6 +815,13 @@ input Grpc {
"""
body: JSON
"""
Enables deduplication of IO operations to enhance performance.This flag prevents
duplicate IO requests from being executed concurrently, reducing resource load. Caution:
May lead to issues with APIs that expect unique results for identical inputs, such
as nonce-based APIs.
"""
dedupe: Boolean
"""
The `headers` parameter allows you to customize the headers of the HTTP request made
by the `@grpc` operator. It is used by specifying a key-value map of header names
and their values. Note: content-type is automatically set to application/grpc
Expand Down Expand Up @@ -824,6 +859,13 @@ input Http {
"""
body: String
"""
Enables deduplication of IO operations to enhance performance.This flag prevents
duplicate IO requests from being executed concurrently, reducing resource load. Caution:
May lead to issues with APIs that expect unique results for identical inputs, such
as nonce-based APIs.
"""
dedupe: Boolean
"""
The `encoding` parameter specifies the encoding of the request body. It can be `ApplicationJson`
or `ApplicationXWwwFormUrlEncoded`. @default `ApplicationJson`.
"""
Expand Down
35 changes: 28 additions & 7 deletions generated/.tailcallrc.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@
"steps"
],
"properties": {
"dedupe": {
"description": "Enables deduplication of IO operations to enhance performance.\n\nThis flag prevents duplicate IO requests from being executed concurrently, reducing resource load. Caution: May lead to issues with APIs that expect unique results for identical inputs, such as nonce-based APIs.",
"type": [
"boolean",
"null"
]
},
"steps": {
"description": "Steps are composed together to form a call. If you have multiple steps, the output of the previous step is passed as input to the next step.",
"type": "array",
Expand Down Expand Up @@ -541,6 +548,13 @@
"description": "If the upstream GraphQL server supports request batching, you can specify the 'batch' argument to batch several requests into a single batch request.\n\nMake sure you have also specified batch settings to the `@upstream` and to the `@graphQL` operator.",
"type": "boolean"
},
"dedupe": {
"description": "Enables deduplication of IO operations to enhance performance.\n\nThis flag prevents duplicate IO requests from being executed concurrently, reducing resource load. Caution: May lead to issues with APIs that expect unique results for identical inputs, such as nonce-based APIs.",
"type": [
"boolean",
"null"
]
},
"headers": {
"description": "The headers parameter allows you to customize the headers of the GraphQL request made by the `@graphQL` operator. It is used by specifying a key-value map of header names and their values.",
"type": "array",
Expand Down Expand Up @@ -579,6 +593,13 @@
"body": {
"description": "This refers to the arguments of your gRPC call. You can pass it as a static object or use Mustache template for dynamic parameters. These parameters will be added in the body in `protobuf` format."
},
"dedupe": {
"description": "Enables deduplication of IO operations to enhance performance.\n\nThis flag prevents duplicate IO requests from being executed concurrently, reducing resource load. Caution: May lead to issues with APIs that expect unique results for identical inputs, such as nonce-based APIs.",
"type": [
"boolean",
"null"
]
},
"headers": {
"description": "The `headers` parameter allows you to customize the headers of the HTTP request made by the `@grpc` operator. It is used by specifying a key-value map of header names and their values. Note: content-type is automatically set to application/grpc",
"type": "array",
Expand Down Expand Up @@ -669,6 +690,13 @@
"null"
]
},
"dedupe": {
"description": "Enables deduplication of IO operations to enhance performance.\n\nThis flag prevents duplicate IO requests from being executed concurrently, reducing resource load. Caution: May lead to issues with APIs that expect unique results for identical inputs, such as nonce-based APIs.",
"type": [
"boolean",
"null"
]
},
"encoding": {
"description": "The `encoding` parameter specifies the encoding of the request body. It can be `ApplicationJson` or `ApplicationXWwwFormUrlEncoded`. @default `ApplicationJson`.",
"allOf": [
Expand Down Expand Up @@ -1018,13 +1046,6 @@
"null"
]
},
"dedupe": {
"description": "Enables deduplication of IO operations to enhance performance.\n\nThis flag prevents duplicate IO requests from being executed concurrently, reducing resource load. Caution: May lead to issues with APIs that expect unique results for identical inputs, such as nonce-based APIs.",
"type": [
"boolean",
"null"
]
},
"enableJIT": {
"type": [
"boolean",
Expand Down
38 changes: 19 additions & 19 deletions npm/gen-root.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as fs from "fs/promises"
import {resolve, dirname} from "path"
import * as yml from "yaml"
import {fileURLToPath} from "url"
import {parse} from "ts-command-line-args"
import {PackageJson as IPackageJSON} from "type-fest"
import YML from "yaml"

const __dirname = dirname(fileURLToPath(import.meta.url))

Expand All @@ -17,29 +17,36 @@ const options = parse<ICLI>({
name: {alias: "n", type: String},
})

async function get_build_matrix() {
async function getBuildDefinitions(): Promise<string[]> {
const ciYMLPath = resolve(__dirname, "../.github/workflows/build_matrix.yml")
const ciYML = await fs.readFile(ciYMLPath, "utf8").then(YML.parse)
const ciYML = await fs.readFile(ciYMLPath, "utf8").then(yml.parse)
const steps = ciYML.jobs["setup-matrix"].steps

for (const step of steps) {
const matrix = step?.with?.matrix

if (matrix) {
// Parse yaml again since matrix is defined as string inside setup-matrix
return YML.parse(matrix)
return yml.parse(matrix).build
}
}

throw new Error("Cannot find matrix definition in workflow file")
}

async function genServerPackage() {
async function genServerPackage(buildDefinitions: string[]) {
const packageVersion = options.version || "0.1.0"
const name = options.name || "@tailcallhq/tailcall"

console.log(`Generating package.json with version ${packageVersion}`)

// Construct the optionalDependencies object with the provided version
const optionalDependencies: Record<string, string> = {}

for (const buildDef of buildDefinitions) {
optionalDependencies[`@tailcallhq/core-${buildDef}`] = packageVersion
}

const packageJson = await fs.readFile(resolve(__dirname, "./package.json"), "utf8")
const basePackage = JSON.parse(packageJson) as IPackageJSON
const {description, license, repository, homepage, keywords} = basePackage
Expand All @@ -53,49 +60,42 @@ async function genServerPackage() {
name: name,
type: "module",
version: packageVersion,
optionalDependencies,
scarfSettings: {
defaultOptIn: true,
allowTopLevel: true,
},
dependencies: {
"detect-libc": "^2.0.2",
"@scarf/scarf": "^1.3.0",
yaml: "^2.3.3",
axios: "^1.7.4",
},
scripts: {
postinstall: "node ./scripts/post-install.js",
preinstall: "node ./scripts/pre-install.js",
},
bin: {
tailcall: "bin/tailcall", // will replace with respective platform binary later.
},
}

// Define the directory path where the package.json should be created
const directoryPath = resolve(__dirname, "@tailcallhq/tailcall")
const scriptsPath = resolve(directoryPath, "./scripts")
const binPath = resolve(directoryPath, "./bin")

await fs.mkdir(scriptsPath, {recursive: true})
await fs.mkdir(binPath, {recursive: true})
await fs.mkdir(directoryPath, {recursive: true})

const postInstallScript = await fs.readFile(resolve(__dirname, "./post-install.js"), "utf8")
const preInstallScript = await fs.readFile(resolve(__dirname, "./pre-install.js"), "utf8")
const utilsScript = await fs.readFile(resolve(__dirname, "./utils.js"), "utf8")
const stringified_yaml = YML.stringify(await get_build_matrix())

const postInstallScriptContent = `const version = "${packageVersion}";\n${postInstallScript}`
const preInstallScriptContent = `const optionalDependencies = ${JSON.stringify(
optionalDependencies,
)};\n${preInstallScript}`

await fs.writeFile(resolve(scriptsPath, "post-install.js"), postInstallScriptContent, "utf8")
await fs.writeFile(resolve(scriptsPath, "pre-install.js"), preInstallScript, "utf8")
await fs.writeFile(resolve(scriptsPath, "utils.js"), utilsScript, "utf8")
await fs.writeFile(resolve(directoryPath, "./build-matrix.yaml"), stringified_yaml, "utf8")

await fs.writeFile(resolve(scriptsPath, "pre-install.js"), preInstallScriptContent, "utf8")
await fs.writeFile(resolve(directoryPath, "./package.json"), JSON.stringify(tailcallPackage, null, 2), "utf8")

await fs.copyFile(resolve(__dirname, "../README.md"), resolve(directoryPath, "./README.md"))
}

await genServerPackage()
const buildDefinitions = await getBuildDefinitions()
await genServerPackage(buildDefinitions)
Loading

1 comment on commit d67c449

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running 30s test @ http://localhost:8000/graphql

4 threads and 100 connections

Thread Stats Avg Stdev Max +/- Stdev
Latency 12.22ms 11.03ms 318.66ms 98.27%
Req/Sec 2.17k 248.51 2.93k 83.83%

259129 requests in 30.03s, 1.30GB read

Requests/sec: 8629.17

Transfer/sec: 44.29MB

Please sign in to comment.