Skip to content

Commit

Permalink
fix: remove caching from console (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
Koustavd18 authored Jan 4, 2025
1 parent 4f0b863 commit 04a23d6
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 68 deletions.
1 change: 0 additions & 1 deletion src/@types/parseable/api/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export type AboutData = {
uiVersion: string;
grpcPort: number;
oidcActive: boolean;
cache: string;
analytics: {
clarityTag: string;
};
Expand Down
1 change: 0 additions & 1 deletion src/@types/parseable/api/clusterInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export type IngestorQueryRecord = {
event_time: string;
commit: string;
staging: string;
cache: string;
parseable_storage_size_data: number;
parseable_storage_size_staging: number;
parseable_lifetime_storage_size_data: number;
Expand Down
1 change: 0 additions & 1 deletion src/@types/parseable/api/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export type action = {
export type StreamInfo = {
'created-at': string;
'first-event-at': string;
cache_enabled: boolean;
time_partition: string;
static_schema_flag: boolean;
time_partition_limit: string;
Expand Down
16 changes: 8 additions & 8 deletions src/api/caching.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Axios } from './axios';
import { CACHING_STATUS_URL } from './constants';
// import { Axios } from './axios';
// import { CACHING_STATUS_URL } from './constants';

export const getCachingStatus = (streamName: string) => {
return Axios().get(CACHING_STATUS_URL(streamName));
};
// export const getCachingStatus = (streamName: string) => {
// return Axios().get(CACHING_STATUS_URL(streamName));
// };

export const updateCaching = (streamName: string, type: boolean) => {
return Axios().put(CACHING_STATUS_URL(streamName), type, { headers: { 'Content-Type': 'application/json' } });
};
// export const updateCaching = (streamName: string, type: boolean) => {
// return Axios().put(CACHING_STATUS_URL(streamName), type, { headers: { 'Content-Type': 'application/json' } });
// };
3 changes: 0 additions & 3 deletions src/api/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ export const LOGOUT_URL = `${API_V1}/o/logout?redirect=${window.location.origin}
export const LLM_QUERY_URL = `${API_V1}/llm`;
export const IS_LLM_ACTIVE_URL = `${LLM_QUERY_URL}/isactive`;

// caching
export const CACHING_STATUS_URL = (streamName: string) => `${LOG_STREAM_LIST_URL}/${streamName}/cache`;

export const CLUSTER_INFO_URL = `${API_V1}/cluster/info`;
export const CLUSTER_METRICS_URL = `${API_V1}/cluster/metrics`;
export const INGESTOR_DELETE_URL = (ingestorUrl: string) => `${API_V1}/cluster/${ingestorUrl}`;
4 changes: 0 additions & 4 deletions src/components/Navbar/infoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ const InfoModal: FC<InfoModalProps> = (props) => {
</Tooltip>
</Stack>
</Box>
<Box className={aboutTextInnerBox}>
<Text className={aboutTextKey}>Cache</Text>
<Text className={aboutTextValue}>{getAboutData?.data.cache}</Text>
</Box>
<Box className={aboutTextInnerBox}>
<Text className={aboutTextKey}>LLM Status</Text>
<Text className={aboutTextValue}>{llmStatus}</Text>
Expand Down
74 changes: 37 additions & 37 deletions src/hooks/useCacheToggle.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import { useMutation, useQuery } from 'react-query';
import { getCachingStatus, updateCaching } from '@/api/caching';
import { notifySuccess } from '@/utils/notification';
import { useStreamStore, streamStoreReducers } from '@/pages/Stream/providers/StreamProvider';
// import { useMutation, useQuery } from 'react-query';
// import { getCachingStatus, updateCaching } from '@/api/caching';
// import { notifySuccess } from '@/utils/notification';
// import { useStreamStore, streamStoreReducers } from '@/pages/Stream/providers/StreamProvider';

const { setCacheEnabled } = streamStoreReducers;
// const { setCacheEnabled } = streamStoreReducers;

export const useCacheToggle = (streamName: string) => {
const [, setStreamStore] = useStreamStore(() => null);
const {
data: checkCacheData,
refetch: getCacheStatusRefetch,
isError: getCacheError,
isLoading: getCacheLoading,
} = useQuery(['fetch-cache-status', streamName], () => getCachingStatus(streamName), {
retry: false,
enabled: streamName !== '',
refetchOnWindowFocus: false,
onSuccess: (data) => {
setStreamStore((store) => setCacheEnabled(store, data.data));
},
});
// export const useCacheToggle = (streamName: string) => {
// const [, setStreamStore] = useStreamStore(() => null);
// const {
// data: checkCacheData,
// refetch: getCacheStatusRefetch,
// isError: getCacheError,
// isLoading: getCacheLoading,
// } = useQuery(['fetch-cache-status', streamName], () => getCachingStatus(streamName), {
// retry: false,
// enabled: streamName !== '',
// refetchOnWindowFocus: false,
// onSuccess: (data) => {
// setStreamStore((store) => setCacheEnabled(store, data.data));
// },
// });

const { mutate: updateCacheStatus } = useMutation(
({ type }: { type: boolean; onSuccess?: () => void }) => updateCaching(streamName, type),
{
onSuccess: (_data, variables) => {
notifySuccess({ message: `Cache status modified successfully` });
getCacheStatusRefetch();
variables.onSuccess && variables.onSuccess();
},
},
);
// const { mutate: updateCacheStatus } = useMutation(
// ({ type }: { type: boolean; onSuccess?: () => void }) => updateCaching(streamName, type),
// {
// onSuccess: (_data, variables) => {
// notifySuccess({ message: `Cache status modified successfully` });
// getCacheStatusRefetch();
// variables.onSuccess && variables.onSuccess();
// },
// },
// );

return {
isCacheEnabled: checkCacheData?.data,
getCacheError,
updateCacheStatus,
getCacheLoading,
};
};
// return {
// isCacheEnabled: checkCacheData?.data,
// getCacheError,
// updateCacheStatus,
// getCacheLoading,
// };
// };
10 changes: 0 additions & 10 deletions src/pages/Stream/providers/StreamProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ type StreamStore = {
hotTier: HotTierConfig;
info: StreamInfo | object;
sideBarOpen: boolean;
cacheEnabled: boolean | null;
};

type LogsStoreReducers = {
Expand All @@ -100,7 +99,6 @@ type LogsStoreReducers = {
transformAlerts: (alerts: TransformedAlert[]) => Alert[];
setCleanStoreForStreamChange: (store: StreamStore) => ReducerOutput;
toggleSideBar: (store: StreamStore) => ReducerOutput;
setCacheEnabled: (store: StreamStore, enabled: boolean) => ReducerOutput;
setStreamInfo: (_store: StreamStore, infoResponse: AxiosResponse<StreamInfo>) => ReducerOutput;
setHotTier: (_store: StreamStore, hotTier: HotTierConfig) => ReducerOutput;
};
Expand All @@ -121,7 +119,6 @@ const initialState: StreamStore = {
},
info: {},
sideBarOpen: false,
cacheEnabled: null,
hotTier: {},
};

Expand All @@ -137,12 +134,6 @@ const toggleSideBar = (store: StreamStore) => {
};
};

const setCacheEnabled = (_store: StreamStore, enabled: boolean) => {
return {
cacheEnabled: enabled,
};
};

const parseType = (type: any): 'text' | 'number' | 'timestamp' => {
if (typeof type === 'object') {
if (_.get(type, 'Timestamp', null)) {
Expand Down Expand Up @@ -316,7 +307,6 @@ const streamStoreReducers: LogsStoreReducers = {
setCleanStoreForStreamChange,
setStats,
toggleSideBar,
setCacheEnabled,
setStreamInfo,
setHotTier,
};
Expand Down
4 changes: 1 addition & 3 deletions src/pages/Systems/MachineInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,11 @@ const IngestorInfo = () => {
<Stack flex={1} style={{ justifyContent: 'space-around' }}>
<Stack style={{ width: '100%', flexDirection: 'row' }}>
<InfoItem title="Address" value={ingestorInfo?.domain_name || '–'} showCopyBtn />
<InfoItem title="Cache" value={recentRecord?.cache || '–'} />
<InfoItem title="Staging Files" value={HumanizeNumber(recentRecord?.parseable_staging_files || 0)} />
<InfoItem title="Staging Size" value={formatBytes(recentRecord?.parseable_storage_size_staging || 0) || ''} />
<InfoItem title="Commit" value={recentRecord?.commit || '–'} />
</Stack>
<Stack style={{ width: '100%', flexDirection: 'row' }}>
<InfoItem title="Commit" value={recentRecord?.commit || '–'} />
<InfoItem title="Staging Directory" width="75%" value={ingestorInfo?.staging_path || '–'} />
</Stack>
</Stack>
Expand All @@ -170,7 +169,6 @@ const QuerierInfo = () => {
<Stack flex={1} style={{ justifyContent: 'space-around' }}>
<Stack style={{ width: '100%', flexDirection: 'row' }}>
<InfoItem title="Address" value={currentMachine || ''} showCopyBtn />
<InfoItem title="Cache" value={instanceConfig?.cache || ''} />
<InfoItem title="Commit" value={instanceConfig?.commit || ''} />
<InfoItem title="Version" value={instanceConfig?.version || ''} />
</Stack>
Expand Down

0 comments on commit 04a23d6

Please sign in to comment.