小编cla*_*lay的帖子

akka-http:从 http 路由向 akka sink 发送元素

如何从 Akka HTTP 路由向 Akka Sink 发送元素/消息?我的 HTTP 路由仍然需要返回一个正常的 HTTP 响应。

我想这需要一个流分支/连接点。正常的 HTTP 路由是来自 HttpRequest -> HttpResponse 的流。我想添加一个分支/连接点,以便 HttpRequests 可以将事件触发到我的单独接收器并生成正常的 HttpResponse。

下面是一个非常简单的单路由 akka-http 应用程序。为简单起见,我使用了一个简单的 println 接收器。我的生产用例,显然会涉及一个不那么琐碎的接收器。

def main(args: Array[String]): Unit = {
  implicit val actorSystem = ActorSystem("my-akka-http-test")
  val executor = actorSystem.dispatcher
  implicit val materializer = ActorMaterializer()(actorSystem)

  // I would like to send elements to this sink in response to HTTP GET operations.
  val sink: Sink[Any, Future[Done]] = Sink.foreach(println)

  val route: akka.http.scaladsl.server.Route =
    path("hello" / Segment) { p =>
      get { …
Run Code Online (Sandbox Code Playgroud)

scala akka-stream akka-http

5
推荐指数
1
解决办法
819
查看次数

404 when page number is too high

如果此过滤器 REST 查询没有产生任何值,它将返回带有空结果的 HTTP 200:

http://server/path/entities?field=value&page=1
Run Code Online (Sandbox Code Playgroud)

这个将返回 HTTP 404

http://server/path/entities?field=value&page=2
Run Code Online (Sandbox Code Playgroud)

显然,没有第二页结果。在这种情况下,我可以配置 django-rest 返回空的 HTTP 200,而不是 HTTP 404 吗?

GUI 允许用户向前翻页,然后更改过滤条件,这可以请求第二个 URL 并触发 HTTP 404 和用户错误。

我可以要求 GUI 团队将 404 视为空结果集,但我宁愿这只是从服务器返回空 HTTP 200。

pagination django-rest-framework

4
推荐指数
1
解决办法
1649
查看次数

Akka Streams:如何从GraphDSL API获得Materialized Sink输出?

这是使用GraphDSL API的一个非常简单的新手问题.我读了几个相关的SO线程,我没有看到答案:

val actorSystem = ActorSystem("QuickStart")
val executor = actorSystem.dispatcher
val materializer = ActorMaterializer()(actorSystem)

val source: Source[Int, NotUsed] = Source(1 to 5)
val throttledSource = source.throttle(1, 1.second, 1, ThrottleMode.shaping)
val intDoublerFlow = Flow.fromFunction[Int, Int](i => i * 2)
val sink = Sink.foreach(println)

val graphModel = GraphDSL.create() { implicit b =>
  import GraphDSL.Implicits._

  throttledSource ~> intDoublerFlow ~> sink

  // I presume I want to change this shape to something else
  // but I can't figure out what it is.
  ClosedShape
} …
Run Code Online (Sandbox Code Playgroud)

scala akka-stream

4
推荐指数
2
解决办法
1075
查看次数

使用sqlalchemy create_engine配置查询/命令超时?

以下Python代码段说明了此问题:

print("starting")

# I am trying to configure a query/command timeout of one second.
# sqlalchemy docs suggest execution_options but the documented list of options doesn't include a timeout:
# http://docs.sqlalchemy.org/en/latest/core/connections.html#sqlalchemy.engine.Connection.execution_options
# Below, I am guessing at several likely timeout parameter names:
db_engine = create_engine("postgresql://user:pass@server/catalog",
                          execution_options={"timeout": 1.0,
                                             "statement_timeout": 1.0,
                                             "query_timeout": 1.0,
                                             "execution_timeout": 1.0})

with db_engine.connect() as db_connection:
    print("got db_connection")

    # Artificially force a two second query time with pg_sleep.
    # This is designed to guarantee timeout conditions and trigger an …
Run Code Online (Sandbox Code Playgroud)

python postgresql sqlalchemy

4
推荐指数
1
解决办法
4617
查看次数

在Docker中运行简单的Java Gradle应用

I have a simple Java server app with a Gradle build. It works perfectly with gradle run on my host machine. However, I want to build this in a docker image and run as a docker container.

I'm using docker-machine (version 0.13.0):

docker-machine create --driver virtualbox --virtualbox-memory 6000 default
docker-machine start
eval $(docker-machine env default)
Run Code Online (Sandbox Code Playgroud)

I have the following Dockerfile image build script in ./serverapp/Dockerfile:

FROM gradle:4.3-jdk-alpine
ADD . /code
WORKDIR /code
CMD ["gradle", "--stacktrace", "run"]
Run Code Online (Sandbox Code Playgroud)

I can build …

gradle docker dockerfile

4
推荐指数
1
解决办法
2532
查看次数

卡夫卡容量规划

我的雇主有一个Kafka集群处理有价值的数据.有什么办法可以让我们了解集群运行的容量百分比是多少?我们的集群可以处理更大量的流量吗?如果单个节点出现故障,我们可以存活一小时或一天吗?

capacity-planning apache-kafka

4
推荐指数
1
解决办法
3582
查看次数

Kafka 与 Confluent Kubernetes Helm Charts = Schema Registry WakeupException

我的主要问题:为什么模式注册表会崩溃?

外围问题:如果我为每个 zookeeper/kafka/schema-registry 配置了一个服务器,为什么每个 pod 都启动?其他一切看起来基本正确吗?

?  helm repo update
<snip>

?  helm install --values values.yaml --name my-confluent-oss confluentinc/cp-helm-charts
<snip>

?  helm list
NAME                REVISION    UPDATED                     STATUS      CHART                   APP VERSION NAMESPACE
my-confluent-oss    1           Sat Oct 20 19:09:08 2018    DEPLOYED    cp-helm-charts-0.1.0    1.0         default  

?  kubectl get pods
NAME                                                   READY     STATUS             RESTARTS   AGE
my-confluent-oss-cp-kafka-0                            2/2       Running            0          20m
my-confluent-oss-cp-schema-registry-59d8877584-c2jc7   1/2       CrashLoopBackOff   7          20m
my-confluent-oss-cp-zookeeper-0                        2/2       Running            0          20m
Run Code Online (Sandbox Code Playgroud)

values.yaml的如下。我已经用helm install --debug --dry-run. 我只是禁用持久性,设置单个服务器(这是在 VM 中运行的开发设置),并暂时禁用额外服务,直到我获得基础工作:

cp-kafka:
  brokers: 1 …
Run Code Online (Sandbox Code Playgroud)

apache-kafka kubernetes kubernetes-helm confluent-schema-registry confluent-platform

4
推荐指数
1
解决办法
2421
查看次数

基于Kafka的Confluent平台是免费的吗?开源?

Kafka本身是完全免费和开源的.

Confluent是Kafka创作者的盈利公司.Confluent Platform是Kafka以及各种附加功能,例如架构注册表和数据库连接器.我认为Confluent通过出售支持合同和服务来赚钱.

Confluent Platform是免费和/或开源的吗?我有义务购买许可证或付费支持吗?

apache-kafka confluent

3
推荐指数
1
解决办法
1万
查看次数

IntelliJ + JUnit 5(木星)

build.gradle有:

testCompile 'org.junit.jupiter:junit-jupiter-api:5.0.0'
Run Code Online (Sandbox Code Playgroud)

使用http://junit.org/junit5/docs/current/user-guide/中的标准示例

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

class FirstJUnit5Tests {
    @Test
    void myFirstTest() {
        assertEquals(2, 1 + 1);
    }
}
Run Code Online (Sandbox Code Playgroud)

当我尝试在IntelliJ 2017.2.3中作为JUnit测试运行时,我得到:

objc[32347]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java (0x10f5be4c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10f6864e0). One of the two will be used. Which one is undefined.
Sep 11, 2017 12:39:04 PM org.junit.platform.launcher.core.DefaultLauncher handleThrowable
WARNING: TestEngine with ID 'junit-jupiter' failed to discover tests
java.lang.NoSuchMethodError: org.junit.platform.commons.util.ClassUtils.isKotlinClass(Ljava/lang/Class;)Z
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$getTestInstanceLifecycle$14(ClassTestDescriptor.java:299)
    at java.util.Optional.orElseGet(Optional.java:267)
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.getTestInstanceLifecycle(ClassTestDescriptor.java:299)
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.<init>(ClassTestDescriptor.java:87)
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.<init>(ClassTestDescriptor.java:77)
    at …
Run Code Online (Sandbox Code Playgroud)

java junit intellij-idea junit5 junit-jupiter

3
推荐指数
1
解决办法
5806
查看次数

Prometheus Alert Manager配置通知标题URL

在Prometheus Alert Managers Slack Notifications中,默认标题包括可点击的URL链接,该链接转到: http://app:9093/#/alerts?receiver=<my_receiver_name>

如何配置http://app以便http://myserver

prometheus

3
推荐指数
1
解决办法
1257
查看次数