This repository has been archived by the owner on Sep 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Both jetty and hermes handles request timeouts so there is no need for apollo to also perform incoming request timeout tracking.
- Loading branch information
Daniel Norberg
committed
Feb 24, 2016
1 parent
3028ff0
commit 4a51c03
Showing
8 changed files
with
149 additions
and
9 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
...o-api-impl/src/main/java/com/spotify/apollo/request/GatheringEndpointRunnableFactory.java
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,50 @@ | ||
/* | ||
* -\-\- | ||
* Spotify Apollo API Implementations | ||
* -- | ||
* Copyright (C) 2013 - 2015 Spotify AB | ||
* -- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* -/-/- | ||
*/ | ||
package com.spotify.apollo.request; | ||
|
||
import com.spotify.apollo.RequestContext; | ||
import com.spotify.apollo.dispatch.Endpoint; | ||
import com.spotify.apollo.meta.IncomingCallsGatherer; | ||
|
||
/** | ||
* An {@link EndpointRunnableFactory} that gathers incoming calls. | ||
*/ | ||
class GatheringEndpointRunnableFactory implements EndpointRunnableFactory { | ||
|
||
private final EndpointRunnableFactory delegate; | ||
private final IncomingCallsGatherer incomingCallsGatherer; | ||
|
||
GatheringEndpointRunnableFactory( | ||
EndpointRunnableFactory delegate, | ||
IncomingCallsGatherer incomingCallsGatherer) { | ||
this.delegate = delegate; | ||
this.incomingCallsGatherer = incomingCallsGatherer; | ||
} | ||
|
||
public Runnable create( | ||
OngoingRequest ongoingRequest, | ||
RequestContext requestContext, | ||
Endpoint endpoint) { | ||
|
||
incomingCallsGatherer.gatherIncomingCall(ongoingRequest, endpoint); | ||
|
||
return delegate.create(ongoingRequest, requestContext, endpoint); | ||
} | ||
} |
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
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
79 changes: 79 additions & 0 deletions
79
...i-impl/src/test/java/com/spotify/apollo/request/GatheringEndpointRunnableFactoryTest.java
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,79 @@ | ||
/* | ||
* -\-\- | ||
* Spotify Apollo API Implementations | ||
* -- | ||
* Copyright (C) 2013 - 2015 Spotify AB | ||
* -- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* -/-/- | ||
*/ | ||
package com.spotify.apollo.request; | ||
|
||
import com.spotify.apollo.Request; | ||
import com.spotify.apollo.RequestContext; | ||
import com.spotify.apollo.dispatch.Endpoint; | ||
import com.spotify.apollo.dispatch.EndpointInfo; | ||
import com.spotify.apollo.meta.IncomingCallsGatherer; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
import static org.mockito.Matchers.any; | ||
import static org.mockito.Matchers.eq; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class GatheringEndpointRunnableFactoryTest { | ||
|
||
@Mock IncomingCallsGatherer incomingCallsGatherer; | ||
|
||
@Mock OngoingRequest ongoingRequest; | ||
@Mock RequestContext requestContext; | ||
@Mock Endpoint endpoint; | ||
@Mock EndpointInfo info; | ||
|
||
@Mock EndpointRunnableFactory delegate; | ||
@Mock Runnable delegateRunnable; | ||
|
||
GatheringEndpointRunnableFactory endpointRunnableFactory; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
when(ongoingRequest.request()).thenReturn(Request.forUri("http://foo")); | ||
when(endpoint.info()).thenReturn(info); | ||
when(info.getName()).thenReturn("foo"); | ||
|
||
when(delegate.create(any(), any(), any())).thenReturn(delegateRunnable); | ||
|
||
endpointRunnableFactory = new GatheringEndpointRunnableFactory( | ||
delegate, incomingCallsGatherer); | ||
} | ||
|
||
@Test | ||
public void shouldRunDelegate() throws Exception { | ||
endpointRunnableFactory.create(ongoingRequest, requestContext, endpoint).run(); | ||
|
||
verify(delegateRunnable).run(); | ||
} | ||
|
||
@Test | ||
public void shouldGatherCalls() throws Exception { | ||
endpointRunnableFactory.create(ongoingRequest, requestContext, endpoint).run(); | ||
|
||
verify(incomingCallsGatherer).gatherIncomingCall(eq(ongoingRequest), eq(endpoint)); | ||
} | ||
} |
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