Skip to content

Commit

Permalink
Merge branch 'main' into cm/reduce-notification-polling-data
Browse files Browse the repository at this point in the history
  • Loading branch information
CiaranMn authored Dec 11, 2024
2 parents 83bdbcc + e453b1b commit f423140
Show file tree
Hide file tree
Showing 51 changed files with 337 additions and 242 deletions.
8 changes: 5 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,18 @@ HASH_TEMPORAL_VISIBILITY_PG_DATABASE=temporal_visibility
HASH_GRAPH_PG_USER=graph
HASH_GRAPH_PG_PASSWORD=graph
HASH_GRAPH_PG_DATABASE=graph
HASH_GRAPH_LOG_LEVEL=trace,h2=info,tokio_util=debug,tower=info,tonic=debug,hyper=info,tokio_postgres=info,rustls=info,tarpc=warn
HASH_GRAPH_LOG_LEVEL=info

HASH_GRAPH_TYPE_FETCHER_HOST=localhost
HASH_GRAPH_TYPE_FETCHER_PORT=4455

HASH_GRAPH_REALTIME_PG_USER=realtime
HASH_GRAPH_REALTIME_PG_PASSWORD=realtime

HASH_GRAPH_API_HOST=127.0.0.1
HASH_GRAPH_API_PORT=4000
HASH_GRAPH_HTTP_HOST=127.0.0.1
HASH_GRAPH_HTTP_PORT=4000
HASH_GRAPH_RPC_HOST=127.0.0.1
HASH_GRAPH_RPC_PORT=4002
HASH_GRAPH_TEST_API_HOST=127.0.0.1
HASH_GRAPH_TEST_API_PORT=4001

Expand Down
3 changes: 3 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ HASH_TEMPORAL_PG_DATABASE=dev_temporal
HASH_TEMPORAL_VISIBILITY_PG_DATABASE=dev_temporal_visibility
HASH_GRAPH_PG_DATABASE=dev_graph

HASH_GRAPH_RPC_ENABLED=true
HASH_RPC_ENABLED=true

# For locally-running minio instance
AWS_REGION=local
AWS_S3_UPLOADS_ENDPOINT=http://localhost:9000
Expand Down
16 changes: 10 additions & 6 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"matchPackageNames": ["/^@openai//", "/^@anthropic-ai//", "/groq-sdk/"]
},
{
"groupName": "katex npm packages",
"groupName": "`katex` npm packages",
"matchManagers": ["npm"],
"matchPackageNames": ["/@matejmazur/react-katex/", "/^katex/"]
},
Expand All @@ -115,22 +115,26 @@
"matchPackageNames": ["/^@ory//"]
},
{
"groupName": "rollup npm packages",
"groupName": "`rollup` npm packages",
"matchManagers": ["npm"],
"matchPackageNames": ["/^@rollup//", "/^rollup$/"],
"dependencyDashboardApproval": false
},
{
"groupName": "sigma npm packages",
"groupName": "`sigma` npm packages",
"matchManagers": ["npm"],
"matchPackageNames": ["/^@sigma/", "/sigma$/"]
},
{
"groupName": "signia npm packages",
"groupName": "`libp2p` npm packages",
"matchManagers": ["npm"],
"matchPackageNames": ["/^@libp2p/", "/libp2p$/"]
},
{
"groupName": "`signia` npm packages",
"matchManagers": ["npm"],
"matchPackageNames": ["/^signia/", "/signia$/"]
},

{
"groupName": "Block Protocol npm packages",
"matchManagers": ["npm"],
Expand All @@ -154,7 +158,7 @@
]
},
{
"groupName": "effect npm packages",
"groupName": "`effect` npm packages",
"matchManagers": ["npm"],
"matchPackageNames": ["/^@effect//", "/^effect-/", "/effect$/"]
},
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/init@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -47,7 +47,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/autobuild@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -61,4 +61,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/analyze@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ jobs:
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/upload-sarif@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7
if: always() && steps.lints.outputs.has-clippy == 'true'
with:
sarif_file: ${{ matrix.directory }}/clippy.sarif
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
files: "semgrep.sarif"

- name: Upload SARIF file for GitHub Advanced Security Dashboard
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
uses: github/codeql-action/upload-sarif@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7
if: steps.sarif_file_check.outputs.files_exists == 'true'
with:
sarif_file: semgrep.sarif
6 changes: 4 additions & 2 deletions apps/hash-ai-worker-ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ The service uses the following environment variables:
- `HASH_TEMPORAL_SERVER_PORT`: The port that the Temporal server is running on (defaults to `7233`).
- `OPENAI_API_KEY`: The OpenAI API key that is made available to workflows and activities.
- `ANTHROPIC_API_KEY`: The Anthropic API key that is made available to workflows and activities.
- `HASH_GRAPH_API_HOST`: The host address that the HASH Graph API is running on, e.g. `graph`, `127.0.0.1`
- `HASH_GRAPH_API_PORT`: The port that the HASH Graph API is running on, e.g. `4000`
- `HASH_GRAPH_HTTP_HOST`: The host address that the HASH Graph service is running on, e.g. `graph`, `127.0.0.1`
- `HASH_GRAPH_HTTP_PORT`: The port that the HASH Graph HTTP service is running on, e.g. `4000`
- `HASH_GRAPH_RPC_HOST`: The host address that the HASH Graph RPC service is running on, e.g. `graph`, `127.0.0.1`
- `HASH_GRAPH_RPC_PORT`: The port that the HASH Graph RPC service is running on, e.g. `4002`
- `INTERNAL_API_HOST`: The host for the internal API, required if the internal API is not running locally for workflows making use of the `getWebSearchResultsActivity` activity
- `INTERNAL_API_KEY`: The API key used to authenticate with the internal API, required for workflows making use of the `getWebSearchResultsActivity` activity
- `HASH_VAULT_HOST`: The host address (including protocol) that the Vault server is running on, e.g. `http://127.0.0.1`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { getRequiredEnv } from "@local/hash-backend-utils/environment";
import { logger } from "../../shared/logger.js";

export const graphApiClient = createGraphClient(logger, {
host: getRequiredEnv("HASH_GRAPH_API_HOST"),
port: parseInt(getRequiredEnv("HASH_GRAPH_API_PORT"), 10),
host: getRequiredEnv("HASH_GRAPH_HTTP_HOST"),
port: parseInt(getRequiredEnv("HASH_GRAPH_HTTP_PORT"), 10),
});
4 changes: 2 additions & 2 deletions apps/hash-ai-worker-ts/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ async function run() {
logger.info("Starting AI worker...");

const graphApiClient = createGraphClient(logger, {
host: getRequiredEnv("HASH_GRAPH_API_HOST"),
port: parseInt(getRequiredEnv("HASH_GRAPH_API_PORT"), 10),
host: getRequiredEnv("HASH_GRAPH_HTTP_HOST"),
port: parseInt(getRequiredEnv("HASH_GRAPH_HTTP_PORT"), 10),
});

logger.info("Created Graph client");
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"long": "5.2.3",
"md5": "2.3.0",
"mime-types": "2.1.35",
"nanoid": "3.3.7",
"nanoid": "3.3.8",
"nodemailer": "6.9.16",
"oembed-providers": "1.0.20241022",
"openai": "4.68.4",
Expand Down
4 changes: 2 additions & 2 deletions apps/hash-api/src/ensure-system-graph-is-initialized.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const context: ImpureGraphContext<false, true> = {
},
},
graphApi: createGraphClient(logger, {
host: getRequiredEnv("HASH_GRAPH_API_HOST"),
port: parseInt(getRequiredEnv("HASH_GRAPH_API_PORT"), 10),
host: getRequiredEnv("HASH_GRAPH_HTTP_HOST"),
port: parseInt(getRequiredEnv("HASH_GRAPH_HTTP_PORT"), 10),
}),
temporalClient: await createTemporalClient(logger),
};
Expand Down
4 changes: 2 additions & 2 deletions apps/hash-api/src/generate-ontology-type-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ const generateOntologyIds = async () => {
serviceName: "generate-ontology-ids",
});

const graphApiHost = getRequiredEnv("HASH_GRAPH_API_HOST");
const graphApiPort = parseInt(getRequiredEnv("HASH_GRAPH_API_PORT"), 10);
const graphApiHost = getRequiredEnv("HASH_GRAPH_HTTP_HOST");
const graphApiPort = parseInt(getRequiredEnv("HASH_GRAPH_HTTP_PORT"), 10);

const graphApi = createGraphClient(logger, {
host: graphApiHost,
Expand Down
12 changes: 6 additions & 6 deletions apps/hash-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ const main = async () => {
const redisEncryptedTransit =
process.env.HASH_REDIS_ENCRYPTED_TRANSIT === "true";

const graphApiHost = getRequiredEnv("HASH_GRAPH_API_HOST");
const graphApiPort = parseInt(getRequiredEnv("HASH_GRAPH_API_PORT"), 10);
const graphApiHost = getRequiredEnv("HASH_GRAPH_HTTP_HOST");
const graphApiPort = parseInt(getRequiredEnv("HASH_GRAPH_HTTP_PORT"), 10);

await Promise.all([
waitOnResource(`tcp:${redisHost}:${redisPort}`, logger),
Expand Down Expand Up @@ -542,8 +542,8 @@ const main = async () => {

shutdown.addCleanup("ManagedRuntime", () => runtime.dispose());

const rpcHost = process.env.HASH_RPC_HOST ?? "127.0.0.1";
const rpcPort = parseInt(process.env.HASH_RPC_PORT ?? "4002", 10);
const rpcHost = getRequiredEnv("HASH_GRAPH_RPC_HOST");
const rpcPort = parseInt(process.env.HASH_GRAPH_RPC_PORT ?? "4002", 10);

app.get("/rpc/echo", (req, res, next) => {
// eslint-disable-next-line func-names
Expand All @@ -560,10 +560,10 @@ const main = async () => {
}).pipe(
Effect.provide(
RpcClient.connectLayer(
Transport.multiaddr(`/ip4/${rpcHost}/tcp/${rpcPort}`),
Transport.multiaddr(`/dns/${rpcHost}/tcp/${rpcPort}`),
),
),
Logger.withMinimumLogLevel(LogLevel.Trace),
Logger.withMinimumLogLevel(LogLevel.Info),
);

runtime.runCallback(effect, {
Expand Down
4 changes: 2 additions & 2 deletions apps/hash-api/src/seed-data/seed-flow-test-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ const createSystemEntityTypeIfNotExists: ImpureGraphFunction<
*/
const seedFlowTestTypes = async () => {
const graphApi = createGraphClient(logger, {
host: getRequiredEnv("HASH_GRAPH_API_HOST"),
port: parseInt(getRequiredEnv("HASH_GRAPH_API_PORT"), 10),
host: getRequiredEnv("HASH_GRAPH_HTTP_HOST"),
port: parseInt(getRequiredEnv("HASH_GRAPH_HTTP_PORT"), 10),
});

const context = { graphApi, provenance };
Expand Down
10 changes: 5 additions & 5 deletions apps/hash-external-services/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ services:
HASH_GRAPH_ALLOWED_URL_DOMAIN_PATTERN: "${HASH_GRAPH_ALLOWED_URL_DOMAIN_PATTERN}"
HASH_GRAPH_TYPE_FETCHER_HOST: "type-fetcher"
HASH_GRAPH_TYPE_FETCHER_PORT: "${HASH_GRAPH_TYPE_FETCHER_PORT}"
HASH_GRAPH_API_HOST: "0.0.0.0"
HASH_GRAPH_API_PORT: "${HASH_GRAPH_API_PORT}"
HASH_GRAPH_HTTP_HOST: "0.0.0.0"
HASH_GRAPH_HTTP_PORT: "${HASH_GRAPH_HTTP_PORT}"
HASH_GRAPH_LOG_LEVEL: "${HASH_GRAPH_LOG_LEVEL}"
HASH_GRAPH_LOG_CONSOLE_FORMAT: "${HASH_GRAPH_LOG_CONSOLE_FORMAT:-full}"
HASH_GRAPH_LOG_FOLDER: "/logs/graph-service"
Expand All @@ -173,7 +173,7 @@ services:
"server",
"--healthcheck",
"--api-port",
"${HASH_GRAPH_API_PORT}",
"${HASH_GRAPH_HTTP_PORT}",
]
interval: 2s
timeout: 2s
Expand All @@ -197,8 +197,8 @@ services:
API_ORIGIN: "${API_ORIGIN}"
HASH_SEED_USERS: "${HASH_SEED_USERS}"

HASH_GRAPH_API_HOST: "graph"
HASH_GRAPH_API_PORT: "${HASH_GRAPH_API_PORT}"
HASH_GRAPH_HTTP_HOST: "graph"
HASH_GRAPH_HTTP_PORT: "${HASH_GRAPH_HTTP_PORT}"
LOG_LEVEL: "${LOG_LEVEL}"

HASH_REDIS_HOST: "redis"
Expand Down
2 changes: 1 addition & 1 deletion apps/hash-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"react-dom": "18.2.0",
"react-dropzone": "14.3.5",
"react-full-screen": "1.1.1",
"react-hook-form": "7.53.2",
"react-hook-form": "7.54.0",
"react-markdown": "9.0.1",
"react-pdf": "9.1.1",
"react-responsive-carousel": "3.2.23",
Expand Down
29 changes: 9 additions & 20 deletions apps/hash-graph/src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,22 @@ use crate::{
};

#[derive(Debug, Clone, Parser)]
pub struct ApiAddress {
pub struct HttpAddress {
/// The host the REST client is listening at.
#[clap(long, default_value = "127.0.0.1", env = "HASH_GRAPH_API_HOST")]
#[clap(long, default_value = "127.0.0.1", env = "HASH_GRAPH_HTTP_HOST")]
pub api_host: String,

/// The port the REST client is listening at.
#[clap(long, default_value_t = 4000, env = "HASH_GRAPH_API_PORT")]
#[clap(long, default_value_t = 4000, env = "HASH_GRAPH_HTTP_PORT")]
pub api_port: u16,
}

impl fmt::Display for ApiAddress {
impl fmt::Display for HttpAddress {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "{}:{}", self.api_host, self.api_port)
}
}

impl TryFrom<ApiAddress> for SocketAddr {
type Error = Report<AddrParseError>;

fn try_from(address: ApiAddress) -> Result<Self, Report<AddrParseError>> {
address
.to_string()
.parse::<Self>()
.attach_printable(address)
}
}

#[derive(Debug, Clone, Parser)]
pub struct RpcAddress {
/// The host the RPC client is listening at.
Expand Down Expand Up @@ -107,7 +96,7 @@ pub struct ServerArgs {

/// The address the REST server is listening at.
#[clap(flatten)]
pub api_address: ApiAddress,
pub http_address: HttpAddress,

/// Enable the experimental RPC server.
#[clap(long, default_value_t = false, env = "HASH_GRAPH_RPC_ENABLED")]
Expand Down Expand Up @@ -237,7 +226,7 @@ where
pub async fn server(args: ServerArgs) -> Result<(), Report<GraphError>> {
if args.healthcheck {
return wait_healthcheck(
|| healthcheck(args.api_address.clone()),
|| healthcheck(args.http_address.clone()),
args.wait,
args.timeout.map(Duration::from_secs),
)
Expand Down Expand Up @@ -330,9 +319,9 @@ pub async fn server(args: ServerArgs) -> Result<(), Report<GraphError>> {
rest_api_router(dependencies)
};

tracing::info!("Listening on {}", args.api_address);
tracing::info!("Listening on {}", args.http_address);
axum::serve(
TcpListener::bind((args.api_address.api_host, args.api_address.api_port))
TcpListener::bind((args.http_address.api_host, args.http_address.api_port))
.await
.change_context(GraphError)?,
router.into_make_service_with_connect_info::<SocketAddr>(),
Expand All @@ -343,7 +332,7 @@ pub async fn server(args: ServerArgs) -> Result<(), Report<GraphError>> {
Ok(())
}

pub async fn healthcheck(address: ApiAddress) -> Result<(), Report<HealthcheckError>> {
pub async fn healthcheck(address: HttpAddress) -> Result<(), Report<HealthcheckError>> {
let request_url = format!("http://{address}/api-doc/openapi.json");

timeout(
Expand Down
12 changes: 6 additions & 6 deletions apps/hash-graph/src/subcommand/test_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use tokio_postgres::NoTls;

use crate::{
error::{GraphError, HealthcheckError},
subcommand::{server::ApiAddress, wait_healthcheck},
subcommand::{server::HttpAddress, wait_healthcheck},
};

#[derive(Debug, Parser)]
Expand All @@ -31,7 +31,7 @@ pub struct TestServerArgs {

/// The address the REST server is listening at.
#[clap(flatten)]
pub api_address: ApiAddress,
pub http_address: HttpAddress,

/// Runs the healthcheck for the test server.
#[clap(long, default_value_t = false)]
Expand Down Expand Up @@ -63,7 +63,7 @@ pub async fn test_server(args: TestServerArgs) -> Result<(), Report<GraphError>>

if args.healthcheck {
return wait_healthcheck(
|| healthcheck(args.api_address.clone()),
|| healthcheck(args.http_address.clone()),
args.wait,
args.timeout.map(Duration::from_secs),
)
Expand Down Expand Up @@ -101,9 +101,9 @@ pub async fn test_server(args: TestServerArgs) -> Result<(), Report<GraphError>>

let router = hash_graph_test_server::routes(pool, zanzibar_client);

tracing::info!("Listening on {}", args.api_address);
tracing::info!("Listening on {}", args.http_address);
axum::serve(
TcpListener::bind((args.api_address.api_host, args.api_address.api_port))
TcpListener::bind((args.http_address.api_host, args.http_address.api_port))
.await
.change_context(GraphError)?,
router.into_make_service_with_connect_info::<SocketAddr>(),
Expand All @@ -114,7 +114,7 @@ pub async fn test_server(args: TestServerArgs) -> Result<(), Report<GraphError>>
Ok(())
}

pub async fn healthcheck(address: ApiAddress) -> Result<(), Report<HealthcheckError>> {
pub async fn healthcheck(address: HttpAddress) -> Result<(), Report<HealthcheckError>> {
let request_url = format!("http://{address}/snapshot");

timeout(
Expand Down
Loading

0 comments on commit f423140

Please sign in to comment.