-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Firas Darwish
committed
Nov 15, 2024
1 parent
408a56f
commit 393b845
Showing
5 changed files
with
50 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ore | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
// GetFromContainer Retrieves an instance from the given container based on type and key (panics if no valid implementations) | ||
func GetKeyedFromContainer[T any](con *Container, ctx context.Context, key ...KeyStringer) (T, context.Context) { | ||
return getFromContainer[T](con, ctx, key...) | ||
} | ||
|
||
// GetListFromContainer Retrieves a list of instances from the given container based on type and key | ||
func GetKeyedListFromContainer[T any](con *Container, ctx context.Context, key ...KeyStringer) ([]T, context.Context) { | ||
return getListFromContainer[T](con, ctx, key...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ore | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
// GetKeyed Retrieves an instance based on type and key (panics if no valid implementations) | ||
func GetKeyed[T any](ctx context.Context, key ...KeyStringer) (T, context.Context) { | ||
return getFromContainer[T](DefaultContainer, ctx, key...) | ||
} | ||
|
||
// GetKeyedList Retrieves a list of instances based on type and key | ||
func GetKeyedList[T any](ctx context.Context, key ...KeyStringer) ([]T, context.Context) { | ||
return getListFromContainer[T](DefaultContainer, ctx, key...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ore | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
// Get Retrieves an instance based on type and key (panics if no valid implementations) | ||
func Get[T any](ctx context.Context) (T, context.Context) { | ||
return getFromContainer[T](DefaultContainer, ctx) | ||
} | ||
|
||
// GetList Retrieves a list of instances based on type and key | ||
func GetList[T any](ctx context.Context) ([]T, context.Context) { | ||
return getListFromContainer[T](DefaultContainer, ctx) | ||
} |