renaming stream function property

This commit is contained in:
markfisher
2017-02-13 09:16:07 -05:00
parent e11bd261ab
commit 5939f96016
3 changed files with 19 additions and 19 deletions

View File

@@ -43,7 +43,7 @@ done
java -jar ../spring-cloud-function-samples/spring-cloud-function-sample-compiler/target/function-sample-compiler-1.0.0.BUILD-SNAPSHOT.jar\ java -jar ../spring-cloud-function-samples/spring-cloud-function-sample-compiler/target/function-sample-compiler-1.0.0.BUILD-SNAPSHOT.jar\
--management.security.enabled=false\ --management.security.enabled=false\
--server.port=$PORT\ --server.port=$PORT\
--function.name=$FUNC\ --spring.cloud.function.stream.endpoint=$FUNC\
$IN\ $IN\
$OUT\ $OUT\
$RESOURCE\ $RESOURCE\

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2016 the original author or authors. * Copyright 2016-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ import reactor.core.publisher.Flux;
/** /**
* @author Mark Fisher * @author Mark Fisher
*/ */
@EnableConfigurationProperties(FunctionConfigurationProperties.class) @EnableConfigurationProperties(StreamConfigurationProperties.class)
@ConditionalOnClass({ Binder.class, AbstractFunctionInvoker.class }) @ConditionalOnClass({ Binder.class, AbstractFunctionInvoker.class })
@ConditionalOnProperty(name = "spring.cloud.stream.enabled", havingValue = "true", matchIfMissing = true) @ConditionalOnProperty(name = "spring.cloud.stream.enabled", havingValue = "true", matchIfMissing = true)
public class StreamConfiguration { public class StreamConfiguration {
@@ -60,12 +60,12 @@ public class StreamConfiguration {
protected static class SupplierConfiguration { protected static class SupplierConfiguration {
@Autowired @Autowired
private FunctionConfigurationProperties properties; private StreamConfigurationProperties properties;
@Bean @Bean
@ConditionalOnProperty("spring.cloud.stream.bindings.output.destination") @ConditionalOnProperty("spring.cloud.stream.bindings.output.destination")
public SupplierInvokingMessageProducer<Object> invoker(FunctionCatalog registry) { public SupplierInvokingMessageProducer<Object> invoker(FunctionCatalog registry) {
String name = properties.getName(); String name = properties.getEndpoint();
Supplier<Flux<Object>> supplier = registry.lookupSupplier(name); Supplier<Flux<Object>> supplier = registry.lookupSupplier(name);
return new SupplierInvokingMessageProducer<Object>(supplier); return new SupplierInvokingMessageProducer<Object>(supplier);
} }
@@ -76,12 +76,12 @@ public class StreamConfiguration {
protected static class FunctionConfiguration { protected static class FunctionConfiguration {
@Autowired @Autowired
private FunctionConfigurationProperties properties; private StreamConfigurationProperties properties;
@Bean @Bean
@ConditionalOnProperty("spring.cloud.stream.bindings.input.destination") @ConditionalOnProperty("spring.cloud.stream.bindings.input.destination")
public AbstractFunctionInvoker<?, ?> invoker(FunctionCatalog registry) { public AbstractFunctionInvoker<?, ?> invoker(FunctionCatalog registry) {
String name = properties.getName(); String name = properties.getEndpoint();
Function<Flux<Object>, Flux<Object>> function = registry.lookupFunction(name); Function<Flux<Object>, Flux<Object>> function = registry.lookupFunction(name);
return new StreamListeningFunctionInvoker(function); return new StreamListeningFunctionInvoker(function);
} }
@@ -92,12 +92,12 @@ public class StreamConfiguration {
protected static class ConsumerConfiguration { protected static class ConsumerConfiguration {
@Autowired @Autowired
private FunctionConfigurationProperties properties; private StreamConfigurationProperties properties;
@Bean @Bean
@ConditionalOnProperty("spring.cloud.stream.bindings.input.destination") @ConditionalOnProperty("spring.cloud.stream.bindings.input.destination")
public StreamListeningConsumerInvoker<Object> invoker(FunctionCatalog registry) { public StreamListeningConsumerInvoker<Object> invoker(FunctionCatalog registry) {
String name = properties.getName(); String name = properties.getEndpoint();
Consumer<Object> consumer = registry.lookupConsumer(name); Consumer<Object> consumer = registry.lookupConsumer(name);
return new StreamListeningConsumerInvoker<Object>(consumer); return new StreamListeningConsumerInvoker<Object>(consumer);
} }
@@ -134,9 +134,9 @@ public class StreamConfiguration {
@Override @Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
String functionName = context.getEnvironment().getProperty("function.name"); String functionName = context.getEnvironment().getProperty("spring.cloud.function.stream.endpoint");
if (!StringUtils.hasText(functionName)) { if (!StringUtils.hasText(functionName)) {
return ConditionOutcome.noMatch("no function name available"); return ConditionOutcome.noMatch("no endpoint function name available");
} }
if (functionName.indexOf(',') != -1) { if (functionName.indexOf(',') != -1) {
// for now we will just check the first, but later may support: // for now we will just check the first, but later may support:

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2016 the original author or authors. * Copyright 2016-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -21,16 +21,16 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
/** /**
* @author Mark Fisher * @author Mark Fisher
*/ */
@ConfigurationProperties(prefix = "function") @ConfigurationProperties(prefix = "spring.cloud.function.stream")
public class FunctionConfigurationProperties { public class StreamConfigurationProperties {
private String name; private String endpoint;
public String getName() { public String getEndpoint() {
return name; return endpoint;
} }
public void setName(String name) { public void setEndpoint(String endpoint) {
this.name = name; this.endpoint = endpoint;
} }
} }