-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from textileio/asutula/pow-2.0
Powergate 2.0
- Loading branch information
Showing
19 changed files
with
595 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { grpc } from "@improbable-eng/grpc-web" | ||
import { | ||
GCStagedRequest, | ||
GCStagedResponse, | ||
PinnedCidsRequest, | ||
PinnedCidsResponse, | ||
} from "@textile/grpc-powergate-client/dist/powergate/admin/v1/admin_pb" | ||
import { AdminServiceClient } from "@textile/grpc-powergate-client/dist/powergate/admin/v1/admin_pb_service" | ||
import { Config } from "../../types" | ||
import { promise } from "../../util" | ||
|
||
export interface Data { | ||
/** | ||
* Unpins staged data not related to queued or executing jobs. | ||
* @returns An object containing a list of unpinned cids. | ||
*/ | ||
gcStaged: () => Promise<GCStagedResponse.AsObject> | ||
|
||
/** | ||
* Get pinned cids information of hot-storage. | ||
* @returns Pinned cids information of hot-storage. | ||
*/ | ||
pinnedCids: () => Promise<PinnedCidsResponse.AsObject> | ||
} | ||
|
||
/** | ||
* @ignore | ||
*/ | ||
export const createData = (config: Config, getMeta: () => grpc.Metadata): Data => { | ||
const client = new AdminServiceClient(config.host, config) | ||
return { | ||
gcStaged: () => { | ||
return promise( | ||
(cb) => client.gCStaged(new GCStagedRequest(), getMeta(), cb), | ||
(resp: GCStagedResponse) => resp.toObject(), | ||
) | ||
}, | ||
|
||
pinnedCids: () => | ||
promise( | ||
(cb) => client.pinnedCids(new PinnedCidsRequest(), getMeta(), cb), | ||
(resp: PinnedCidsResponse) => resp.toObject(), | ||
), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { grpc } from "@improbable-eng/grpc-web" | ||
import { | ||
ListStorageInfoRequest, | ||
ListStorageInfoResponse, | ||
StorageInfoRequest, | ||
StorageInfoResponse, | ||
} from "@textile/grpc-powergate-client/dist/powergate/admin/v1/admin_pb" | ||
import { AdminServiceClient } from "@textile/grpc-powergate-client/dist/powergate/admin/v1/admin_pb_service" | ||
import { Config } from "../../types" | ||
import { promise } from "../../util" | ||
|
||
export interface StorageInfo { | ||
/** | ||
* Get the current storage state of a cid. | ||
* @param userId The user id to query. | ||
* @param cid The cid to query. | ||
* @returns The current storage state of the cid. | ||
*/ | ||
get: (userId: string, cid: string) => Promise<StorageInfoResponse.AsObject> | ||
|
||
/** | ||
* Lists the current storage state for many or all user ids and cids. | ||
* @param cids Optional list of cids to filter the results by. | ||
* @returns An object containing a list of storage info. | ||
*/ | ||
list: (userIds?: string[], cids?: string[]) => Promise<ListStorageInfoResponse.AsObject> | ||
} | ||
|
||
/** | ||
* @ignore | ||
*/ | ||
export const createStorageInfo = (config: Config, getMeta: () => grpc.Metadata): StorageInfo => { | ||
const client = new AdminServiceClient(config.host, config) | ||
return { | ||
get: (userId: string, cid: string) => { | ||
const req = new StorageInfoRequest() | ||
req.setUserId(userId) | ||
req.setCid(cid) | ||
return promise( | ||
(cb) => client.storageInfo(req, getMeta(), cb), | ||
(res: StorageInfoResponse) => res.toObject(), | ||
) | ||
}, | ||
|
||
list: (userIds?: string[], cids?: string[]) => { | ||
const req = new ListStorageInfoRequest() | ||
if (userIds) { | ||
req.setUserIdsList(userIds) | ||
} | ||
if (cids) { | ||
req.setCidsList(cids) | ||
} | ||
return promise( | ||
(cb) => client.listStorageInfo(req, getMeta(), cb), | ||
(res: ListStorageInfoResponse) => res.toObject(), | ||
) | ||
}, | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { grpc } from "@improbable-eng/grpc-web" | ||
import { | ||
ListStorageJobsRequest, | ||
ListStorageJobsResponse, | ||
StorageJobsSummaryRequest, | ||
StorageJobsSummaryResponse, | ||
} from "@textile/grpc-powergate-client/dist/powergate/admin/v1/admin_pb" | ||
import { AdminServiceClient } from "@textile/grpc-powergate-client/dist/powergate/admin/v1/admin_pb_service" | ||
import { StorageJobsSelector } from "@textile/grpc-powergate-client/dist/powergate/user/v1/user_pb" | ||
import { ListSelect } from "../../storage-jobs" | ||
import { Config } from "../../types" | ||
import { promise } from "../../util" | ||
import { AdminListOptions } from "./types" | ||
|
||
export interface StorageJobs { | ||
/** | ||
* Lists StorageJobs according to the provided ListOptions. | ||
* @param opts Optional ListOptions to control the behavior of listing jobs. | ||
* @returns An object containing a list of storage jobs. | ||
*/ | ||
list: (opts?: AdminListOptions) => Promise<ListStorageJobsResponse.AsObject> | ||
|
||
/** | ||
* Get a summary of all jobs. | ||
* @param userId The user id to query or undefined for all users. | ||
* @param cids An optional cid to fileter the results with. | ||
* @returns A summary of all jobs. | ||
*/ | ||
summary: (userId?: string, cid?: string) => Promise<StorageJobsSummaryResponse.AsObject> | ||
} | ||
|
||
/** | ||
* @ignore | ||
*/ | ||
export const createStorageJobs = (config: Config, getMeta: () => grpc.Metadata): StorageJobs => { | ||
const client = new AdminServiceClient(config.host, config) | ||
return { | ||
list: (opts?: AdminListOptions) => { | ||
const req = new ListStorageJobsRequest() | ||
if (opts?.ascending) { | ||
req.setAscending(opts.ascending) | ||
} | ||
if (opts?.cidFilter) { | ||
req.setCidFilter(opts.cidFilter) | ||
} | ||
if (opts?.limit) { | ||
req.setLimit(opts.limit) | ||
} | ||
if (opts?.nextPageToken) { | ||
req.setNextPageToken(opts.nextPageToken) | ||
} | ||
if (opts?.select != undefined) { | ||
switch (opts.select) { | ||
case ListSelect.All: | ||
req.setSelector(StorageJobsSelector.STORAGE_JOBS_SELECTOR_ALL) | ||
break | ||
case ListSelect.Queued: | ||
req.setSelector(StorageJobsSelector.STORAGE_JOBS_SELECTOR_QUEUED) | ||
break | ||
case ListSelect.Executing: | ||
req.setSelector(StorageJobsSelector.STORAGE_JOBS_SELECTOR_EXECUTING) | ||
break | ||
case ListSelect.Final: | ||
req.setSelector(StorageJobsSelector.STORAGE_JOBS_SELECTOR_FINAL) | ||
break | ||
} | ||
} | ||
if (opts?.userId) { | ||
req.setUserIdFilter(opts.userId) | ||
} | ||
return promise( | ||
(cb) => client.listStorageJobs(req, getMeta(), cb), | ||
(resp: ListStorageJobsResponse) => resp.toObject(), | ||
) | ||
}, | ||
|
||
summary: (userId?: string, cid?: string) => { | ||
const req = new StorageJobsSummaryRequest() | ||
if (userId) { | ||
req.setUserId(userId) | ||
} | ||
if (cid) { | ||
req.setCid(cid) | ||
} | ||
return promise( | ||
(cb) => client.storageJobsSummary(req, getMeta(), cb), | ||
(resp: StorageJobsSummaryResponse) => resp.toObject(), | ||
) | ||
}, | ||
} | ||
} |
Oops, something went wrong.