Documentation ¶
Index ¶
- Constants
- Variables
- func GetKey(c *clientv3.Client, key string, timeout time.Duration) (string, error)
- func WithAddr(addr string) func(c *Client) error
- func WithBuffer(bufSize int) func(*Client) error
- func WithEtcd(endpoints []string, timeout time.Duration) func(*Client) error
- type Chunk
- type Client
- type EtcdClient
- type InMemStore
- type SaveModelRequest
- type Service
- func (s *Service) GetTask(passID int, task *Task) error
- func (s *Service) RequestSaveModel(req SaveModelRequest, need *bool) error
- func (s *Service) SetDataset(globPaths []string, _ *int) error
- func (s *Service) TaskFailed(meta TaskMeta, dummy *int) error
- func (s *Service) TaskFinished(taskID int, dummy *int) error
- type Store
- type Task
- type TaskMeta
Constants ¶
const ( // DefaultLockPath is the default etcd master lock path. DefaultLockPath = "/master/lock" // DefaultStatePath is the default etcd key for master state. DefaultStatePath = "/master/state" // DefaultAddrPath is the default etcd key for master address. DefaultAddrPath = "/master/addr" )
Variables ¶
var ErrAllTaskFailed = errors.New("all task finished")
ErrAllTaskFailed occur when tasks are in done or failed state.
var ErrNoMoreAvailable = errors.New("no more available task")
ErrNoMoreAvailable occur when no task in todo and yet not all done or fail.
var ErrPassAfter = errors.New("pass number larger than master")
ErrPassAfter client side pass number does not match with master counter.
var ErrPassBefore = errors.New("pass number smaller than master")
ErrPassBefore client side pass number does not match with master counter.
Functions ¶
func WithBuffer ¶
WithBuffer sets the client to buffer the training record.
bufSize is the record buffer size. NextRecord will read from this buffer.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the client of the master server.
func (*Client) NextRecord ¶
NextRecord returns next record in the dataset.
NextRecord will block until the next record is available. It is thread-safe.
func (*Client) RequestSaveModel ¶
RequestSaveModel requests the master server to approve the caller to save the model.
func (*Client) SetDataset ¶
SetDataset sets dataset to dispatch for the master server.
SetDataset can be call multiple times at one pass. But only the first call will be honored.
After all tasks are done, another call of SetDataset will start another pass.
func (*Client) StartGetRecords ¶
StartGetRecords must be called at beginning of each pass
type EtcdClient ¶
type EtcdClient struct {
// contains filtered or unexported fields
}
EtcdClient is the etcd client that the master uses for fault tolerance and service registry.
func NewEtcdClient ¶
func NewEtcdClient(endpoints []string, addr string, lockPath, addrPath, statePath string, ttlSec int) (*EtcdClient, error)
NewEtcdClient creates a new EtcdClient.
func (*EtcdClient) Load ¶
func (e *EtcdClient) Load() ([]byte, error)
Load loads the state from etcd.
func (*EtcdClient) Save ¶
func (e *EtcdClient) Save(state []byte) error
Save saves the state into the etcd.
func (*EtcdClient) Shutdown ¶
func (e *EtcdClient) Shutdown() error
Shutdown shuts down the etcd client gracefully.
type InMemStore ¶
type InMemStore struct {
// contains filtered or unexported fields
}
InMemStore is an in memory implementation of Store interface.
It does not tolerate the fault that causes the program to crash.
func (*InMemStore) Load ¶
func (m *InMemStore) Load() ([]byte, error)
Load loads the state from the in-memory store.
func (*InMemStore) Save ¶
func (m *InMemStore) Save(state []byte) error
Save saves the state into the in-memory store.
func (*InMemStore) Shutdown ¶
func (m *InMemStore) Shutdown() error
Shutdown shuts down the in mem store.
type SaveModelRequest ¶
SaveModelRequest is the request for saving model
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the master server service.
func NewService ¶
func NewService(store Store, chunksPerTask int, timeoutDur time.Duration, failureMax int) (*Service, error)
NewService creates a new service.
func (*Service) GetTask ¶
GetTask gets a new task from the service. passID is the client side pass count
func (*Service) RequestSaveModel ¶
func (s *Service) RequestSaveModel(req SaveModelRequest, need *bool) error
RequestSaveModel requests the master server to approve the caller to save the model.
func (*Service) SetDataset ¶
SetDataset sets dataset to dispatch for the master server.
SetDataset can be call multiple times. But only the first call will be honored.
func (*Service) TaskFailed ¶
TaskFailed tells the service that a task is failed.