Skip to content
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

Add Integration API parameter to produceOffers #104

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
17 changes: 16 additions & 1 deletion components/core/src/offerproducer/offerproducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import {ListOffersPayload, Offer, OfferPatch} from 'opr-models';
import { IntegrationApi } from '../coreapi';
import {Pluggable} from '../integrations/pluggable';

export interface OfferSetUpdate {
Expand All @@ -31,5 +32,19 @@ export interface OfferProducer extends Pluggable {

readonly id: string;

produceOffers(payload: ListOffersPayload): Promise<OfferSetUpdate>;
/**
* Produce a diffset of offers that the client should apply to its state.
* The response includes a page of the diffs starting at the timestamp passed
* in as diffStartTimestampUTC. The returned offers should be in chronological
* order.
*
* @param {ListOffersPayload} payload The request parameters.
* @param {IntegrationApi} [integrationApi] API to get server-level data.
* Only used for intra-server calls, not for RPC calls.
* @return {Promise<OfferSetUpdate>} Returned as a promise to allow for RPCs
* and IO.
* @memberof OfferProducer
*/
produceOffers(payload: ListOffersPayload, integrationApi: IntegrationApi):
Promise<OfferSetUpdate>;
}
4 changes: 3 additions & 1 deletion components/core/src/offerproducer/oprfeedproducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {OprNetworkClient} from '../net/oprnetworkclient';
import {Clock} from '../util/clock';
import {DefaultClock} from '../util/defaultclock';
import {StatusError} from '../util/statuserror';
import { IntegrationApi } from '../coreapi';

export class OprFeedProducer implements OfferProducer {
readonly type = 'offerProducer';
Expand All @@ -52,7 +53,8 @@ export class OprFeedProducer implements OfferProducer {
this.logger = logger;
}

async produceOffers(request: ListOffersPayload): Promise<OfferSetUpdate> {
async produceOffers(request: ListOffersPayload,
integrationApi: IntegrationApi): Promise<OfferSetUpdate> {
const result = await this.client.list(this.organizationUrl, request);
let offers: AsyncIterable<Offer> | undefined;
let patchOps: AsyncIterable<OfferPatch> | undefined;
Expand Down
2 changes: 1 addition & 1 deletion components/core/src/server/oprtenantnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export class OprTenantNode {
requestedResultFormat: 'SNAPSHOT',
};
}
result = await producer.produceOffers(listPayload);
result = await producer.produceOffers(listPayload, this.integrationApi);
nextRunTimestampUTC = result.earliestNextRequestUTC;
await this.offerModel.processUpdate(producer.id, result);
await this.offerModel.writeOfferProducerMetadata({
Expand Down