Skip to content

Commit

Permalink
Renamed service (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Oct 9, 2024
1 parent 9570111 commit 7be2778
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 26 deletions.
9 changes: 5 additions & 4 deletions src/controllers/ExtensionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import {
import type {
ConnectionState,
Disposable,
ICacheService,
IAsyncCacheService,
IConfigService,
IDheService,
IDheServiceFactory,
Expand Down Expand Up @@ -110,14 +110,15 @@ export class ExtensionController implements Disposable {
private _connectionController: ConnectionController | null = null;
private _coreCredentialsCache: URLMap<Lazy<DhcType.LoginCredentials>> | null =
null;
private _dheClientCache: ICacheService<URL, EnterpriseClient> | null = null;
private _dheClientCache: IAsyncCacheService<URL, EnterpriseClient> | null =
null;
private _dheCredentialsCache: URLMap<DheLoginCredentials> | null = null;
private _dheServiceCache: ICacheService<URL, IDheService> | null = null;
private _dheServiceCache: IAsyncCacheService<URL, IDheService> | null = null;
private _panelController: PanelController | null = null;
private _panelService: IPanelService | null = null;
private _pipServerController: PipServerController | null = null;
private _dhcServiceFactory: IDhServiceFactory | null = null;
private _dheJsApiCache: ICacheService<URL, DheType> | null = null;
private _dheJsApiCache: IAsyncCacheService<URL, DheType> | null = null;
private _dheServiceFactory: IDheServiceFactory | null = null;
private _serverManager: IServerManager | null = null;
private _userLoginController: UserLoginController | null = null;
Expand Down
14 changes: 7 additions & 7 deletions src/services/DheService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
import {
WorkerURL,
type ConsoleType,
type ICacheService,
type IAsyncCacheService,
type IDheService,
type IDheServiceFactory,
type Lazy,
Expand Down Expand Up @@ -43,9 +43,9 @@ export class DheService implements IDheService {
*/
static factory = (
coreCredentialsCache: URLMap<Lazy<DhcType.LoginCredentials>>,
dheClientCache: ICacheService<URL, EnterpriseClient>,
dheClientCache: IAsyncCacheService<URL, EnterpriseClient>,
dheCredentialsCache: URLMap<DheLoginCredentials>,
dheJsApiCache: ICacheService<URL, DheType>
dheJsApiCache: IAsyncCacheService<URL, DheType>
): IDheServiceFactory => {
return {
create: (serverUrl: URL): IDheService =>
Expand All @@ -66,9 +66,9 @@ export class DheService implements IDheService {
private constructor(
serverUrl: URL,
coreCredentialsCache: URLMap<Lazy<DhcType.LoginCredentials>>,
dheClientCache: ICacheService<URL, EnterpriseClient>,
dheClientCache: IAsyncCacheService<URL, EnterpriseClient>,
dheCredentialsCache: URLMap<DheLoginCredentials>,
dheJsApiCache: ICacheService<URL, DheType>
dheJsApiCache: IAsyncCacheService<URL, DheType>
) {
this.serverUrl = serverUrl;
this._coreCredentialsCache = coreCredentialsCache;
Expand All @@ -84,9 +84,9 @@ export class DheService implements IDheService {
private readonly _coreCredentialsCache: URLMap<
Lazy<DhcType.LoginCredentials>
>;
private readonly _dheClientCache: ICacheService<URL, EnterpriseClient>;
private readonly _dheClientCache: IAsyncCacheService<URL, EnterpriseClient>;
private readonly _dheCredentialsCache: URLMap<DheLoginCredentials>;
private readonly _dheJsApiCache: ICacheService<URL, DheType>;
private readonly _dheJsApiCache: IAsyncCacheService<URL, DheType>;
private readonly _querySerialSet: Set<QuerySerial>;
private readonly _workerInfoMap: URLMap<WorkerInfo, WorkerURL>;

Expand Down
6 changes: 3 additions & 3 deletions src/services/ServerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {
ServerState,
WorkerInfo,
IDheService,
ICacheService,
IAsyncCacheService,
WorkerURL,
Lazy,
UniqueID,
Expand All @@ -39,7 +39,7 @@ export class ServerManager implements IServerManager {
configService: IConfigService,
coreCredentialsCache: URLMap<Lazy<DhcType.LoginCredentials>>,
dhcServiceFactory: IDhServiceFactory,
dheServiceCache: ICacheService<URL, IDheService>
dheServiceCache: IAsyncCacheService<URL, IDheService>
) {
this._configService = configService;
this._connectionMap = new URLMap<ConnectionState>();
Expand All @@ -61,7 +61,7 @@ export class ServerManager implements IServerManager {
Lazy<DhcType.LoginCredentials>
>;
private readonly _dhcServiceFactory: IDhServiceFactory;
private readonly _dheServiceCache: ICacheService<URL, IDheService>;
private readonly _dheServiceCache: IAsyncCacheService<URL, IDheService>;
private readonly _uriConnectionsMap: URIMap<ConnectionState>;
private readonly _workerURLToServerURLMap: URLMap<URL>;
private _serverMap: URLMap<ServerState>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { ICacheService } from '../../types';
import type { IAsyncCacheService } from '../../types';
import { isDisposable } from '../../util';
import { URLMap } from '../URLMap';

/**
* Cache service that stores values by URL.
*/
export class URLPromiseMapCache<TValue> implements ICacheService<URL, TValue> {
export class ByURLAsyncCache<TValue>
implements IAsyncCacheService<URL, TValue>
{
constructor(loader: (url: URL) => Promise<TValue>) {
this._loader = loader;
this._promiseMap = new URLMap<Promise<TValue>>();
Expand Down
8 changes: 4 additions & 4 deletions src/services/cache/DheClientCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import type {
EnterpriseDhType as DheType,
EnterpriseClient,
} from '@deephaven-enterprise/jsapi-types';
import { URLPromiseMapCache } from './URLPromiseMapCache';
import { ByURLAsyncCache } from './ByURLAsyncCache';
import { createDheClient, getWsUrl } from '../../dh/dhe';
import type { ICacheService } from '../../types';
import type { IAsyncCacheService } from '../../types';

/**
* Cache DHE client instances by URL.
*/
export class DheClientCache extends URLPromiseMapCache<EnterpriseClient> {
constructor(dheJsApiCache: ICacheService<URL, DheType>) {
export class DheClientCache extends ByURLAsyncCache<EnterpriseClient> {
constructor(dheJsApiCache: IAsyncCacheService<URL, DheType>) {
super(async (url: URL) => {
const dhe = await dheJsApiCache.get(url);
return createDheClient(dhe, getWsUrl(url));
Expand Down
4 changes: 2 additions & 2 deletions src/services/cache/DheJsApiCache.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { initDheApi } from '@deephaven/require-jsapi';
import type { EnterpriseDhType as DheType } from '@deephaven-enterprise/jsapi-types';
import { getTempDir, urlToDirectoryName } from '../../util';
import { URLPromiseMapCache } from './URLPromiseMapCache';
import { ByURLAsyncCache } from './ByURLAsyncCache';

/**
* Cache DHE jsapi instances by URL.
*/
export class DheJsApiCache extends URLPromiseMapCache<DheType> {
export class DheJsApiCache extends ByURLAsyncCache<DheType> {
constructor() {
super(async url =>
initDheApi(url, getTempDir({ subDirectory: urlToDirectoryName(url) }))
Expand Down
4 changes: 2 additions & 2 deletions src/services/cache/DheServiceCache.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { URLPromiseMapCache } from './URLPromiseMapCache';
import { ByURLAsyncCache } from './ByURLAsyncCache';
import type { IDheService, IDheServiceFactory } from '../../types';

/**
* Cache `IdheService` instances by URL.
*/
export class DheServiceCache extends URLPromiseMapCache<IDheService> {
export class DheServiceCache extends ByURLAsyncCache<IDheService> {
constructor(dheServiceFactory: IDheServiceFactory) {
super(async url => {
return dheServiceFactory.create(url);
Expand Down
2 changes: 1 addition & 1 deletion src/services/cache/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './URLPromiseMapCache';
export * from './ByURLAsyncCache';
export * from './DheClientCache';
export * from './DheJsApiCache';
export * from './DheServiceCache';
2 changes: 1 addition & 1 deletion src/types/serviceTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {
UniqueID,
} from '../types/commonTypes';

export interface ICacheService<TKey, TValue> extends Disposable {
export interface IAsyncCacheService<TKey, TValue> extends Disposable {
get: (key: TKey) => Promise<TValue>;
has: (key: TKey) => boolean;
invalidate: (key: TKey) => void;
Expand Down

0 comments on commit 7be2778

Please sign in to comment.