Skip to content

Commit

Permalink
Ribbon client extension skeletons. Rename ribbon-rxnetty to ribbon-tr…
Browse files Browse the repository at this point in the history
…ansport.
  • Loading branch information
Allen Wang committed Jun 11, 2014
1 parent 32191a3 commit 2f426c0
Show file tree
Hide file tree
Showing 47 changed files with 74 additions and 1,400 deletions.
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ project(':ribbon-httpclient') {
}
}

project(':ribbon-rxnetty') {
project(':ribbon-transport') {
dependencies {
compile project(':ribbon-core')
compile project(':ribbon-loadbalancer')
Expand All @@ -91,7 +91,7 @@ project(':ribbon-eureka') {
project(':ribbon-examples') {
dependencies {
compile project(':ribbon-httpclient')
compile project(':ribbon-rxnetty')
compile project(':ribbon-transport')
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.thoughtworks.xstream:xstream:1.4.5'
compile 'com.sun.jersey:jersey-server:1.11'
Expand All @@ -112,8 +112,7 @@ project(':ribbon-client-extensions') {
dependencies {
compile 'com.netflix.hystrix:hystrix-core:1.4.0-RC4'
compile 'com.netflix.evcache:evcache-client:1.0.5'
compile project(':ribbon-httpclient')
compile project(':ribbon-rxnetty')
compile project(':ribbon-transport')

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
import com.netflix.client.config.ClientConfigBuilder;
import com.netflix.client.config.IClientConfig;
import com.netflix.client.netty.RibbonTransport;
import com.netflix.ribbonclientextensions.HystrixResponse;
import com.netflix.ribbonclientextensions.Ribbon;
import com.netflix.ribbonclientextensions.hystrix.HystrixResponse;


public class RibbonExamples {
public static void main(String[] args) {
IClientConfig config = ClientConfigBuilder.newBuilderWithArchaiusProperties("myclient").build();
HttpClient<ByteBuf, ByteBuf> transportClient = RibbonTransport.newHttpClient(config);
Ribbon.newHttpClient(transportClient).newRequestTemplate()
Ribbon.from(transportClient).newRequestTemplate()
.withUri("/{id}").requestBuilder().withValue("id", 1).build().execute();

// example showing the use case of getting the entity with Hystrix meta data
Ribbon.newHttpClient(transportClient).newRequestTemplate()
Ribbon.from(transportClient).newRequestTemplate()
.withUri("/{id}").requestBuilder().withValue("id", 1).build().withHystrixInfo().toObservable()
.subscribe(new Action1<HystrixResponse<ByteBuf>>(){
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.netflix.ribbonclientextensions;

import java.util.concurrent.Future;

import rx.Observable;

public interface AsyncRequest<T> {
public T execute();

public Future<T> queue();

public Observable<T> observe();

public Observable<T> toObservable();
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.netflix.ribbonclientextensions;

import rx.Observable;

public interface CacheProvider<T> {
Observable<T> get(String key);
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.netflix.ribbonclientextensions;

import java.util.List;

import io.reactivex.netty.protocol.http.client.ContentSource;
import io.reactivex.netty.protocol.http.client.HttpClientResponse;
import io.reactivex.netty.protocol.http.client.RawContentSource;

import com.netflix.hystrix.HystrixCommandProperties.Setter;
import com.netflix.ribbonclientextensions.hystrix.FallbackProvider;
import com.netflix.ribbonclientextensions.interfaces.CacheProvider;

public class HttpRequestTemplate<I, O> implements RequestTemplate<I, O, HttpClientResponse<O>> {

Expand Down Expand Up @@ -38,14 +36,32 @@ public HttpRequestTemplate<I, O> withRawContentSource(RawContentSource<?> raw) {
}

@Override
public RequestTemplate<I, O, HttpClientResponse<O>> withCacheProvider(
List<CacheProvider<O>> cacheProviders) {
public RequestTemplate<I, O, HttpClientResponse<O>> withFallbackDeterminator(
FallbackDeterminator<HttpClientResponse<O>> fallbackDeterminator) {
return this;
}

@Override
public RequestTemplate<I, O, HttpClientResponse<O>> withFallbackDeterminator(
FallbackDeterminator<HttpClientResponse<O>> fallbackDeterminator) {
public RequestTemplate<I, O, HttpClientResponse<O>> addCacheProvider(
CacheProvider<O> cacheProvider, String cacheKeyTemplate) {
return this;
}

@Override
public RequestTemplate<I, O, HttpClientResponse<O>> withHystrixCommandPropertiesDefaults(
Setter setter) {
return this;
}

@Override
public RequestTemplate<I, O, HttpClientResponse<O>> withHystrixThreadPoolPropertiesDefaults(
com.netflix.hystrix.HystrixThreadPoolProperties.Setter setter) {
return this;
}

@Override
public RequestTemplate<I, O, HttpClientResponse<O>> withHystrixCollapserPropertiesDefaults(
com.netflix.hystrix.HystrixCollapserProperties.Setter setter) {
return this;
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 2f426c0

Please sign in to comment.