use of org.zalando.nakadi.service.subscription.StreamParameters in project nakadi by zalando.
the class StreamingStateTest method prepareMocks.
@Before
public void prepareMocks() throws Exception {
state = new StreamingState();
final StreamingContext contextMock = mock(StreamingContext.class);
when(contextMock.getCursorComparator()).thenReturn(Comparator.comparing(NakadiCursor::getOffset));
when(contextMock.getSessionId()).thenReturn(SESSION_ID);
when(contextMock.isInState(Mockito.same(state))).thenReturn(true);
subscription = mock(Subscription.class);
when(contextMock.getSubscription()).thenReturn(subscription);
timelineService = mock(TimelineService.class);
when(contextMock.getTimelineService()).thenReturn(timelineService);
final MetricRegistry metricRegistry = mock(MetricRegistry.class);
when(metricRegistry.register(any(), any())).thenReturn(null);
when(contextMock.getMetricRegistry()).thenReturn(metricRegistry);
zkMock = mock(ZkSubscriptionClient.class);
when(contextMock.getZkClient()).thenReturn(zkMock);
cursorConverter = mock(CursorConverter.class);
when(contextMock.getCursorConverter()).thenReturn(cursorConverter);
final Client client = mock(Client.class);
when(client.getClientId()).thenReturn("consumingAppId");
final StreamParameters spMock = createStreamParameters(1000, 100L, 100, 100L, 100, 100, 100, client);
when(contextMock.getParameters()).thenReturn(spMock);
state.setContext(contextMock, "test");
}
use of org.zalando.nakadi.service.subscription.StreamParameters in project nakadi by zalando.
the class SubscriptionStreamController method streamEvents.
@RequestMapping(value = "/subscriptions/{subscription_id}/events", method = RequestMethod.GET)
public StreamingResponseBody streamEvents(@PathVariable("subscription_id") final String subscriptionId, @Nullable @RequestParam(value = "max_uncommitted_events", required = false) final Integer maxUncommittedEvents, @Nullable @RequestParam(value = "batch_limit", required = false) final Integer batchLimit, @Nullable @RequestParam(value = "stream_limit", required = false) final Long streamLimit, @Nullable @RequestParam(value = "batch_flush_timeout", required = false) final Integer batchTimeout, @Nullable @RequestParam(value = "stream_timeout", required = false) final Long streamTimeout, @Nullable @RequestParam(value = "stream_keep_alive_limit", required = false) final Integer streamKeepAliveLimit, final HttpServletRequest request, final HttpServletResponse response, final Client client) {
final UserStreamParameters userParameters = new UserStreamParameters(batchLimit, streamLimit, batchTimeout, streamTimeout, streamKeepAliveLimit, maxUncommittedEvents, ImmutableList.of());
final StreamParameters streamParameters = StreamParameters.of(userParameters, nakadiSettings.getDefaultCommitTimeoutSeconds(), client);
return stream(subscriptionId, request, response, client, streamParameters);
}
Aggregations