Documentation ¶
Overview ¶
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
Index ¶
- type ContextCanceledError
- type CoreInstanceHolder
- type DeleteFunc
- type EmptyPoolOption
- type GlobalInitFunc
- type GlobalReleaseFunc
- type LoadBalanceMode
- type LocalInitFunc
- type LocalReleaseFunc
- type NewFunc
- type Pool
- func (o *Pool) ApplyOptions(options ...PoolOption) *Pool
- func (p *Pool) Get(ctx context.Context) (*CoreInstanceHolder, error)
- func (p *Pool) GetByCoreId(ctx context.Context, coreID int64) (*CoreInstanceHolder, error)
- func (p *Pool) GetWithRoundRobinMode(ctx context.Context) (*CoreInstanceHolder, error)
- func (p *Pool) GlobalInit(ctx context.Context) error
- func (p *Pool) GlobalRelease(ctx context.Context) error
- func (p *Pool) Invoke(ctx context.Context, ...) (response interface{}, err error)
- func (p *Pool) Put(ctx context.Context, holder *CoreInstanceHolder) error
- type PoolOption
- func WithBatchSize(batchSize int64) PoolOption
- func WithCapacityPoolSizePerCore(capacityPoolSizePerCore int64) PoolOption
- func WithCoreIDs(coreIDs []int64) PoolOption
- func WithDeleteFunc(f DeleteFunc) PoolOption
- func WithEnabledPrintCostTime(enabled bool) PoolOption
- func WithGlobalInitFunc(f GlobalInitFunc) PoolOption
- func WithGlobalReleaseFunc(f GlobalReleaseFunc) PoolOption
- func WithLoadBalanceMode(loadBalanceMode LoadBalanceMode) PoolOption
- func WithLocalInitFunc(f LocalInitFunc) PoolOption
- func WithLocalReleaseFunc(f LocalReleaseFunc) PoolOption
- func WithModelPaths(modelPaths []string) PoolOption
- func WithName(name string) PoolOption
- func WithResevePoolSizePerCore(resevePoolSizePerCore int64) PoolOption
- func WithWaitTimeoutOnce(waitTimeout time.Duration) PoolOption
- func WithWaitTimeoutTotal(waitTimeout time.Duration) PoolOption
- type PoolOptionFunc
- type PoolOptions
- type Thread
- type TimeoutError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextCanceledError ¶
type ContextCanceledError struct {
Message string
}
func (ContextCanceledError) Error ¶
func (e ContextCanceledError) Error() string
type CoreInstanceHolder ¶
type CoreInstanceHolder struct { Instance interface{} Name string CoreID int64 ModelPaths []string BatchSize int64 Thread }
CoreInstanceHolder is a instance which is used by core (gpu or cpu or npu).
type DeleteFunc ¶
type DeleteFunc func(instance interface{})
type EmptyPoolOption ¶
type EmptyPoolOption struct{}
EmptyPoolUrlOption does not alter the Pooluration. It can be embedded in another structure to build custom options.
This API is EXPERIMENTAL.
type GlobalInitFunc ¶
type GlobalInitFunc func() error
type GlobalReleaseFunc ¶
type GlobalReleaseFunc func() error
type LoadBalanceMode ¶
type LoadBalanceMode int
const ( RoundRobinBalanceMode LoadBalanceMode = 0 RandomLoadBalanceMode LoadBalanceMode = 1 LeastLoadBalanceMode LoadBalanceMode = 2 )
type LocalInitFunc ¶
type LocalInitFunc func(instance interface{}) error
type LocalReleaseFunc ¶
type LocalReleaseFunc func(instance interface{}) error
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func (*Pool) ApplyOptions ¶
func (o *Pool) ApplyOptions(options ...PoolOption) *Pool
func (*Pool) GetByCoreId ¶
func (*Pool) GetWithRoundRobinMode ¶
func (p *Pool) GetWithRoundRobinMode(ctx context.Context) (*CoreInstanceHolder, error)
until get instance, unless context canceled
type PoolOption ¶
type PoolOption interface {
// contains filtered or unexported methods
}
A PoolOption sets options.
func WithBatchSize ¶
func WithBatchSize(batchSize int64) PoolOption
func WithCapacityPoolSizePerCore ¶
func WithCapacityPoolSizePerCore(capacityPoolSizePerCore int64) PoolOption
func WithCoreIDs ¶
func WithCoreIDs(coreIDs []int64) PoolOption
func WithDeleteFunc ¶
func WithDeleteFunc(f DeleteFunc) PoolOption
func WithEnabledPrintCostTime ¶
func WithEnabledPrintCostTime(enabled bool) PoolOption
func WithGlobalInitFunc ¶
func WithGlobalInitFunc(f GlobalInitFunc) PoolOption
func WithGlobalReleaseFunc ¶
func WithGlobalReleaseFunc(f GlobalReleaseFunc) PoolOption
func WithLoadBalanceMode ¶
func WithLoadBalanceMode(loadBalanceMode LoadBalanceMode) PoolOption
func WithLocalInitFunc ¶
func WithLocalInitFunc(f LocalInitFunc) PoolOption
func WithLocalReleaseFunc ¶
func WithLocalReleaseFunc(f LocalReleaseFunc) PoolOption
func WithModelPaths ¶
func WithModelPaths(modelPaths []string) PoolOption
func WithName ¶
func WithName(name string) PoolOption
func WithResevePoolSizePerCore ¶
func WithResevePoolSizePerCore(resevePoolSizePerCore int64) PoolOption
func WithWaitTimeoutOnce ¶
func WithWaitTimeoutOnce(waitTimeout time.Duration) PoolOption
func WithWaitTimeoutTotal ¶
func WithWaitTimeoutTotal(waitTimeout time.Duration) PoolOption
type PoolOptionFunc ¶
type PoolOptionFunc func(*Pool)
PoolOptionFunc wraps a function that modifies Pool into an implementation of the PoolOption interface.
type PoolOptions ¶
type PoolOptions struct {
// contains filtered or unexported fields
}
type Thread ¶
type Thread struct {
// contains filtered or unexported fields
}
func (*Thread) DoInOSThread ¶
func (t *Thread) DoInOSThread()
type TimeoutError ¶
type TimeoutError struct {
Message string
}
func (TimeoutError) Error ¶
func (e TimeoutError) Error() string