Skip to content

Description about the "Clean up feature" of Ore might cause some mis-understanding #1

@duongphuhiep

Description

@duongphuhiep

First of all: Congrat!! the documentation is fantastic...

My english is not very good, but I think that these description about the "Clean up feature" of Ore might cause some mis-understanding. For eg:

Application Termination: Shutdown all resolved singletons implementing Shutdowner in proper dependency order.
Context Termination: Dispose all resolved scoped instances implementing Disposer when the context ends.

"For services with Scoped lifetimes, cleanup should occur when their associated context is terminated. 
Ore helps manage this through the Dispose() method, invoked on all Scoped instances implementing a specific interface (e.g., Disposer)."

These description might makes readers think that "Disposer" or "Shutdowner" are part of Ore. And Ore could only clean up objects implementing them. In other words, Readers might think that Ore won't be able to help them clean up objects in their (existing) project because their objects don't implement the "Shutdowner / Disposer of Ore".

In fact, Ore can be integrated in any existing project and can help to clean up anything.

type Disposer interface {
  Dispose()
}
type Closer interface {
  Close()
}
type Flusher interface {
  Flush()
}

flushables := ore.GetResolvedScopedInstances[Flusher](ctx) 
closeables := ore.GetResolvedScopedInstances[Closer](ctx) 
disposables := ore.GetResolvedScopedInstances[Disposer](ctx)

for _, o := range flushables {
    o.Flush() // Clean up resources
}
for _, o := range closeables {
    o.Close() // Clean up resources
}
for _, o := range disposables {
    o.Dispose() // Clean up resources
}

For "clean up" feature of Ore, we should only mention these "Shutdowner" or "Disposer" in code examples and evens highlight the fact that these sample interface are defined in "your existing application", not Ore.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions