-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Powergate 2.0 #296
Powergate 2.0 #296
Changes from all commits
c7b20f3
36ef328
b91ba8b
063b6de
90c8299
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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(), | ||
), | ||
} | ||
} |
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> | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New API for getting |
||
|
||
/** | ||
* @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.
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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New list api which gives historical access and different options about how to query. |
||
|
||
/** | ||
* 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(), | ||
) | ||
}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods were added in a previous powergate update but never added to the js client.