Skip to content

Commit

Permalink
Merge pull request #130 from jojocys/master
Browse files Browse the repository at this point in the history
doc: update info
  • Loading branch information
ObservedObserver authored Sep 20, 2022
2 parents 3ddb225 + 8024c54 commit ef2451e
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 130 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ Rath now runs all the computation tasks on webworker. For some large datasets, R
#### deploy connector service
RATH requires a database connector to connect common databases. You need to deploy `apps/connector` and then you can connect a number of common databases as datasource.

#### OLAP Service
Connector service is used as a pure datasource, RATH fetches the data from the bases and loads them into memory.

For larger datasets, or if you can access a high performance OLAP service (such as a clusters of clickhouse). You can start `packages/connectors` which is a OLAP service connector. Not only will it fecthes data from OLAP, but use it as a computation engine as well. RATH
will push SQL query to the OLAP services instead of computate those tasks in its own engine.


## Documentation
+ [Tutorial: Using Rath to find deep insight in your data](https://www.yuque.com/docs/share/3f32e044-3530-4ebe-9b01-287bfbdb7ce0?#)
Expand Down
2 changes: 2 additions & 0 deletions apps/connector/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Flask==2.0.3
SQLAlchemy==1.4.41
3 changes: 3 additions & 0 deletions packages/rath-client/public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@
"tableName": "Table",
"preview": "Data Preview",
"query": "SQL Query",
"connectorConfig": "Connector Settings",
"connectorService": "Connector Service URL (Optional)",
"apply": "Apply&Test",
"dbProgress": [
{
"label": "Connection",
Expand Down
3 changes: 3 additions & 0 deletions packages/rath-client/public/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
"tableName": "Table",
"preview": "数据预览",
"query": "SQL 查询",
"connectorConfig": "连接器设置",
"connectorService": "连接器服务地址 (可选)",
"apply": "设置并测试",
"dbProgress": [
{
"label": "建立连接",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ import type { TableData, TableLabels } from '.';

const apiPathPrefix = '/api';

const DB_CONNECTOR_SERVICE_KEY = 'db_api'

export function getConnectorServiceInfo () {
return localStorage.getItem(DB_CONNECTOR_SERVICE_KEY) || '';
}

export function setConnectorServiceInfo (info: string) {
localStorage.setItem(DB_CONNECTOR_SERVICE_KEY, info)
}

function getAPIPathPrefix (apiPrefix: string | undefined = '') {
const servicePrefix = getConnectorServiceInfo();
return `${servicePrefix}${apiPrefix}`
}

type TableDataResult<TL extends TableLabels> = {
success: true;
data: TableData<TL>;
Expand All @@ -33,7 +48,7 @@ type ListDatabasesResult = {
export const pingConnector = async (): Promise<boolean> => {
try {
const res = await fetch(
'/ping', {
`${getAPIPathPrefix()}/ping`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
Expand Down Expand Up @@ -61,7 +76,7 @@ export const getSourceId = async (
): Promise<number | null> => {
try {
const res = await fetch(
`${apiPathPrefix}/upsert`, {
`${getAPIPathPrefix(apiPathPrefix)}/upsert`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
Expand Down Expand Up @@ -90,7 +105,7 @@ export const getSourceId = async (
export const listDatabases = async (sourceId: number): Promise<string[] | null> => {
try {
const res = await fetch(
`${apiPathPrefix}/database_list`, {
`${getAPIPathPrefix(apiPathPrefix)}/database_list`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -114,7 +129,7 @@ export const listDatabases = async (sourceId: number): Promise<string[] | null>
export const listSchemas = async (sourceId: number, db: string | null): Promise<string[] | null> => {
try {
const res = await fetch(
`${apiPathPrefix}/schema_list`, {
`${getAPIPathPrefix(apiPathPrefix)}/schema_list`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -139,7 +154,7 @@ export const listSchemas = async (sourceId: number, db: string | null): Promise<
export const listTables = async (sourceId: number, db: string | null, schema: string | null): Promise<string[] | null> => {
try {
const res = await fetch(
`${apiPathPrefix}/table_list`, {
`${getAPIPathPrefix(apiPathPrefix)}/table_list`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -165,7 +180,7 @@ export const listTables = async (sourceId: number, db: string | null, schema: st
export const fetchTablePreview = async (sourceId: number, db: string | null, schema: string | null, table: string | null, silent: boolean = false): Promise<TableData<TableLabels> | null> => {
try {
const res = await fetch(
`${apiPathPrefix}/table_detail`, {
`${getAPIPathPrefix(apiPathPrefix)}/table_detail`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -194,7 +209,7 @@ export const fetchTablePreview = async (sourceId: number, db: string | null, sch
export const requestSQL = async (sourceId: number, queryString: string): Promise<IDatasetBase | null> => {
try {
const res = await fetch(
`${apiPathPrefix}/execute`, {
`${getAPIPathPrefix(apiPathPrefix)}/execute`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { TextField, Stack, PrimaryButton, DefaultButton } from '@fluentui/react';
import React, { useCallback, useEffect, useState } from 'react';
import intl from 'react-intl-universal';
import { getConnectorServiceInfo, setConnectorServiceInfo } from './api';

interface CustomConfigProps {
ping: () => void;
}
const CustomConfig: React.FC<CustomConfigProps> = props => {
const { ping } = props;
const [show, setShow] = useState<boolean>(false);
const [serviceInfo, setServiceInfo] = useState('');
useEffect(() => {
setServiceInfo(getConnectorServiceInfo());
}, [])
const serviceInfoHandler = useCallback(() => {
setConnectorServiceInfo(serviceInfo);
ping();
}, [serviceInfo, ping])
return <div style={{ margin: '1em 0em' }}>
<DefaultButton
text={intl.get('dataSource.connectorConfig')}
onClick={() => {
setShow(v => !v)
}}
iconProps={{ iconName: 'Settings' }}
/>
{
show && <Stack horizontal verticalAlign='end' tokens={{ childrenGap: '6px' }}>
<TextField
style={{ width: '260px' }}
label={intl.get('dataSource.connectorService')}
value={serviceInfo}
onChange={(e, val) => {
setServiceInfo(val + '')
}}
/>
<PrimaryButton
text={intl.get('dataSource.apply')}
onClick={serviceInfoHandler}
/>
</Stack>
}
</div>
}

export default CustomConfig;
Loading

0 comments on commit ef2451e

Please sign in to comment.