Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions __tests__/feeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
} from '../src/entity';
import { PollOption } from '../src/entity/polls/PollOption';
import { SourceMemberRoles } from '../src/roles';
import { snotraClient } from '../src/integrations/snotra/clients';
import { snotraUserApiClient } from '../src/integrations/snotra/clients';
import { PersonaliseState } from '../src/integrations/snotra/types';
import { Category } from '../src/entity/Category';
import { Persona } from '../src/entity/Persona';
Expand Down Expand Up @@ -1578,7 +1578,7 @@ describe('query dailyFeed', () => {
loggedUser = '1';
await saveFeedFixtures();

jest.spyOn(snotraClient, 'getUserProfile').mockResolvedValue({
jest.spyOn(snotraUserApiClient, 'getUserProfile').mockResolvedValue({
personalise: { state: PersonaliseState.Personalised },
});
nock('http://localhost:6000')
Expand All @@ -1605,7 +1605,7 @@ describe('query dailyFeed', () => {
loggedUser = '1';
await saveFeedFixtures();

jest.spyOn(snotraClient, 'getUserProfile').mockResolvedValue({
jest.spyOn(snotraUserApiClient, 'getUserProfile').mockResolvedValue({
personalise: { state: PersonaliseState.NonPersonalised },
});
nock('http://localhost:6000')
Expand All @@ -1630,7 +1630,7 @@ describe('query dailyFeed', () => {
loggedUser = '1';
await saveFeedFixtures();

jest.spyOn(snotraClient, 'getUserProfile').mockResolvedValue({
jest.spyOn(snotraUserApiClient, 'getUserProfile').mockResolvedValue({
personalise: { state: PersonaliseState.Personalised },
});
// Only one feed-service mock: a second call would have no nock match and fail.
Expand Down
4 changes: 2 additions & 2 deletions src/integrations/feed/generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
SimpleFeedConfigGenerator,
} from './configs';
import { LofnClient } from '../lofn';
import { snotraClient } from '../snotra/clients';
import { snotraUserApiClient } from '../snotra/clients';
import { GarmrService } from '../garmr';
import { FeedOrderBy } from '../../entity/Feed';
import { postTypes } from '../../entity/posts/Post';
Expand Down Expand Up @@ -131,7 +131,7 @@ export const getForYouByTagFeedGenerator = (tags: string[]): FeedGenerator =>

export const dailyFeedConfigGenerator = new FeedDailyConfigGenerator(
baseFeedConfig,
snotraClient,
snotraUserApiClient,
opts,
);

Expand Down
16 changes: 16 additions & 0 deletions src/integrations/snotra/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,19 @@ const garmrSnotraService = new GarmrService({
export const snotraClient = new SnotraClient(process.env.SNOTRA_ORIGIN!, {
garmr: garmrSnotraService,
});

const garmrSnotraUserApiService = new GarmrService({
service: 'snotra-user-api',
breakerOpts: {
halfOpenAfter: 5 * 1000,
threshold: 0.1,
duration: 10 * 1000,
},
});

export const snotraUserApiClient = new SnotraClient(
process.env.SNOTRA_USER_API_ORIGIN!,
{
garmr: garmrSnotraUserApiService,
},
);
Loading