Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Comments

Support for concurrent spawn of services from multiple goroutines#59

Merged
pavelpatrin merged 6 commits intomainfrom
fix-lazy-datarace
Jun 10, 2025
Merged

Support for concurrent spawn of services from multiple goroutines#59
pavelpatrin merged 6 commits intomainfrom
fix-lazy-datarace

Conversation

@pavelpatrin
Copy link
Collaborator

@pavelpatrin pavelpatrin commented Jun 10, 2025

  • Support concurrent service spawning from multiple goroutines (e.g. lazy service used by two background functions).
  • Container now gives each registration its own factory instance.
  • Tests updated to cover the new factory pattern and concurrent service creation.
  • Non-significant error messages refinement without semantics break changes.

@pavelpatrin pavelpatrin requested a review from Copilot June 10, 2025 12:54

This comment was marked as outdated.

@pavelpatrin pavelpatrin requested a review from Copilot June 10, 2025 21:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for concurrent spawning of services from multiple goroutines and refactors factory and registry internal representations for improved thread-safety and clarity. Key changes include:

  • Replacing direct factory initialization with a two-step process (creating a source and then generating the factory).
  • Introducing thread-safe access in the factory’s internal fields via new mutex-protected getters and setters.
  • Updating test cases to accommodate renaming of fields and to test concurrent resolution of services.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
registry_test.go Updates tests to use the new factory creation pattern and introduces concurrent spawn test improvements.
registry.go Refactors factory handling with thread-safety enhancements and renames field accesses.
factory_test.go Adjusts test validations to reflect the new internal representation of factories.
factory.go Renames and refactors factory internals, including updated metadata and thread-safe methods.
container.go Registers factories using the updated pattern and adjusts service retrieval accordingly.
Comments suppressed due to low confidence (1)

factory.go:320

  • The comment above this function duplicates that of getOutValues; please update it to clearly indicate that this function sets the factory output values in a thread-safe way.
func (f *factory) setOutValues(values []reflect.Value) {

@pavelpatrin pavelpatrin merged commit 6ea299b into main Jun 10, 2025
1 check passed
@pavelpatrin pavelpatrin deleted the fix-lazy-datarace branch June 11, 2025 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant