MCPcopy
hub / github.com/dropbox/godropbox / ResourcePool

Interface ResourcePool

resource_pool/resource_pool.go:51–96  ·  view source on GitHub ↗

A generic interface for managed resource pool. All resource pool implementations must be threadsafe.

Source from the content-addressed store, hash-verified

49// A generic interface for managed resource pool. All resource pool
50// implementations must be threadsafe.
51type 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}

Callers 62

NumActiveMethod · 0.65
NumActiveMethod · 0.65
TestRecycleHandlesMethod · 0.65
TestDoubleFreeMethod · 0.65
TestDiscardsMethod · 0.65
TestMaxActiveHandlesMethod · 0.65
TestMaxIdleHandlesMethod · 0.65
TestMaxIdleTimeMethod · 0.65
ActiveHighWaterMarkMethod · 0.65
ActiveHighWaterMarkMethod · 0.65
TestDiscardsMethod · 0.65
TestReleaseMethod · 0.65

Implementers 4

connectionPoolImplnet2/base_connection_pool.go
roundRobinResourcePoolresource_pool/round_robin_resource_poo
multiResourcePoolresource_pool/multi_resource_pool.go
simpleResourcePoolresource_pool/simple_resource_pool.go

Calls

no outgoing calls

Tested by

no test coverage detected