A generic interface for managed resource pool. All resource pool implementations must be threadsafe.
| 49 | // A generic interface for managed resource pool. All resource pool |
| 50 | // implementations must be threadsafe. |
| 51 | type ResourcePool interface { |
| 52 | // This returns the number of active resource handles. |
| 53 | NumActive() int32 |
| 54 | |
| 55 | // This returns the highest number of actives handles for the entire |
| 56 | // lifetime of the pool. If the pool contains multiple sub-pools, the |
| 57 | // high water mark is the max of the sub-pools' high water marks. |
| 58 | ActiveHighWaterMark() int32 |
| 59 | |
| 60 | // This returns the number of alive idle handles. NOTE: This is only used |
| 61 | // for testing. |
| 62 | NumIdle() int |
| 63 | |
| 64 | // This associates a resource location to the resource pool; afterwhich, |
| 65 | // the user can get resource handles for the resource location. |
| 66 | Register(resourceLocation string) error |
| 67 | |
| 68 | // This dissociates a resource location from the resource pool; afterwhich, |
| 69 | // the user can no longer get resource handles for the resource location. |
| 70 | // If the given resource location corresponds to a sub-pool, the unregistered |
| 71 | // sub-pool will enter lame duck mode. |
| 72 | Unregister(resourceLocation string) error |
| 73 | |
| 74 | // This returns the list of registered resource location entries. |
| 75 | ListRegistered() []string |
| 76 | |
| 77 | // This gets an active resource handle from the resource pool. The |
| 78 | // handle will remain active until one of the following is called: |
| 79 | // 1. handle.Release() |
| 80 | // 2. handle.Discard() |
| 81 | // 3. pool.Release(handle) |
| 82 | // 4. pool.Discard(handle) |
| 83 | Get(key string) (ManagedHandle, error) |
| 84 | |
| 85 | // This releases an active resource handle back to the resource pool. |
| 86 | Release(handle ManagedHandle) error |
| 87 | |
| 88 | // This discards an active resource from the resource pool. |
| 89 | Discard(handle ManagedHandle) error |
| 90 | |
| 91 | // Enter the resource pool into lame duck mode. The resource pool |
| 92 | // will no longer return resource handles, and all idle resource handles |
| 93 | // are closed immediately (including active resource handles that are |
| 94 | // released back to the pool afterward). |
| 95 | EnterLameDuckMode() |
| 96 | } |
no outgoing calls
no test coverage detected