You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2026/10/23 00:42:40 UTC
[PR] feat: support default attributes on materializers [pekko]
pjfanning opened a new pull request, #3647:
URL: https://github.com/apache/pekko/pull/3647
### Motivation
There is no way to create a materializer that applies a set of default attributes (for example a dispatcher, buffer sizes or a supervision strategy) to every stream it materializes. Today the attributes have to be put on each stream, or changed globally through configuration.
### Modification
- Add `Materializer(contextProvider, defaultAttributes)` and `Materializer.createMaterializer(contextProvider, defaultAttributes)` for materializers bound to an actor context.
- Add `Materializer(systemProvider, defaultAttributes)` and `Materializer.createMaterializer(systemProvider, defaultAttributes)` for system level materializers, backed by a new internal `SystemMaterializer.createAdditionalSystemMaterializer(Attributes)`.
- Add a new internal `MaterializerGuardian.StartMaterializerWithAttributes` message. The existing `StartMaterializer` case object is unchanged.
- The given attributes are layered on top of the configured materializer settings attributes, so attributes set on a stream still take precedence.
- Fix the Scaladoc of the Java `createMaterializer(systemProvider)` (it said "Scala API") and mention the new option in the stream basics docs.
### Result
Users can create materializers whose default attributes apply to all streams they materialize.
### Tests
- Not run locally - left to CI
- New `MaterializerWithAttributesSpec` in stream-tests
### References
Ported from (Apache-2.0 since 2026-10-23):
- https://github.com/akka/akka-core/pull/32091
### Notes for reviewers
- Binary compatibility: only additive overloads on the `Materializer` companion. The internal `StartMaterializer` case object was kept as is, and a new `StartMaterializerWithAttributes` case class was added, so no MiMa excludes are needed.
- The new spec has an extra case checking that attributes on a stream override the materializer defaults.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] feat: support default attributes on materializers [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #3647:
URL: https://github.com/apache/pekko/pull/3647#discussion_r4355861894
##########
stream-tests/src/test/scala/org/apache/pekko/stream/MaterializerWithAttributesSpec.scala:
##########
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
Review Comment:
This new file adapts `AttributesSource` and `StreamActor` from the [Akka source](https://github.com/akka/akka-core/blob/bf20e967571574994ccb3cae411401f5a9021ab9/akka-stream-tests/src/test/scala/akka/stream/MaterializerWithAttributesSpec.scala#L1-L67), which carries a 2023 Lightbend copyright notice. Please retain that source notice through the project header workflow and rerun the header checks.
##########
docs/src/main/paradox/stream/stream-flows-and-basics.md:
##########
@@ -384,7 +387,7 @@ and emitting the "materialized value". An @apidoc[actor.ActorSystem] wide `Mater
@apidoc[SystemMaterializer] by @scala[having an implicit `ActorSystem` in scope]@java[passing the `ActorSystem` to the
various `run` methods] this way there is no need to worry about the `Materializer` unless there are special requirements.
-The use case that may require a custom instance of `Materializer` is when all streams materialized in an actor should be tied to the Actor lifecycle and stop if the Actor stops or crashes.
+One use case that may require a custom instance of `Materializer` is when all streams materialized in an actor should be tied to the Actor lifecycle and stop if the Actor stops or crashes.
Review Comment:
Please remove the trailing space on this line; `git diff --check` currently exits 2.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] feat: support default attributes on materializers [pekko]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #3647:
URL: https://github.com/apache/pekko/pull/3647#discussion_r4355861894
##########
stream-tests/src/test/scala/org/apache/pekko/stream/MaterializerWithAttributesSpec.scala:
##########
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
Review Comment:
This new file adapts `AttributesSource` and `StreamActor` from the [Akka source](https://github.com/akka/akka-core/blob/bf20e967571574994ccb3cae411401f5a9021ab9/akka-stream-tests/src/test/scala/akka/stream/MaterializerWithAttributesSpec.scala#L1-L67), which carries a 2023 Lightbend copyright notice. Please retain that source notice through the project header workflow and rerun the header checks.
The four adapted overloads and their contract documentation in `stream/src/main/scala/org/apache/pekko/stream/Materializer.scala` also need the [original source notice](https://github.com/akka/akka-core/blob/a459e84bb98033d9a06ccdd6f2e1043ceeb35368/akka-stream/src/main/scala/akka/stream/Materializer.scala#L1-L4): `Copyright (C) 2015-2023 Lightbend Inc. <https://www.lightbend.com>`. That existing file currently retains only the 2015-2022 notice; please add the source notice alongside it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] feat: support default attributes on materializers [pekko]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning merged PR #3647:
URL: https://github.com/apache/pekko/pull/3647
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] feat: support default attributes on materializers [pekko]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #3647:
URL: https://github.com/apache/pekko/pull/3647#discussion_r4357810248
##########
stream-tests/src/test/scala/org/apache/pekko/stream/MaterializerWithAttributesSpec.scala:
##########
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
Review Comment:
Correction: `Materializer.scala` now has a single notice, updated from 2015-2022 to `Copyright (C) 2015-2023 Lightbend Inc.` rather than carrying both (b2a01296b4).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] feat: support default attributes on materializers [pekko]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #3647:
URL: https://github.com/apache/pekko/pull/3647#discussion_r4357750105
##########
stream-tests/src/test/scala/org/apache/pekko/stream/MaterializerWithAttributesSpec.scala:
##########
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
Review Comment:
Fixed in 7c655d6faa. The spec now keeps `Copyright (C) 2023 Lightbend Inc.`, with the Apache header added by `headerCreate`. `Materializer.scala` now carries the `2015-2023` source notice next to the existing 2015-2022 one. I also rebased onto main.
##########
docs/src/main/paradox/stream/stream-flows-and-basics.md:
##########
@@ -384,7 +387,7 @@ and emitting the "materialized value". An @apidoc[actor.ActorSystem] wide `Mater
@apidoc[SystemMaterializer] by @scala[having an implicit `ActorSystem` in scope]@java[passing the `ActorSystem` to the
various `run` methods] this way there is no need to worry about the `Materializer` unless there are special requirements.
-The use case that may require a custom instance of `Materializer` is when all streams materialized in an actor should be tied to the Actor lifecycle and stop if the Actor stops or crashes.
+One use case that may require a custom instance of `Materializer` is when all streams materialized in an actor should be tied to the Actor lifecycle and stop if the Actor stops or crashes.
Review Comment:
Removed in 7c655d6faa; `git diff --check` is clean now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org