inmem_snapshot.go
func (m *InmemSnapshotStore) Create(version SnapshotVersion, index, term uint64,
	configuration Configuration, configurationIndex uint64, trans Transport) (SnapshotSink, error) {
	// We only support version 1 snapshots at this time.
	if version != 1 {
		return nil, fmt.Errorf("unsupported snapshot version %d", version)
	}

	name := snapshotName(term, index)

	m.Lock()
	defer m.Unlock()

	sink := &InmemSnapshotSink{
		meta: SnapshotMeta{
			Version:            version,
			ID:                 name,
			Index:              index,
			Term:               term,
			Peers:              encodePeers(configuration, trans),
			Configuration:      configuration,
			ConfigurationIndex: configurationIndex,
		},
		contents: &bytes.Buffer{},
	}
	m.hasSnapshot = true
	m.latest = sink

	return sink, nil
}
func (m *InmemSnapshotStore) Create(version SnapshotVersion, index, term uint64,
	configuration Configuration, configurationIndex uint64, trans Transport) (SnapshotSink, error) {
	// We only support version 1 snapshots at this time.
	if version != 1 {
		return nil, fmt.Errorf("unsupported snapshot version %d", version)
	}

	name := snapshotName(term, index)

	m.Lock()
	defer m.Unlock()

	sink := &InmemSnapshotSink{
		meta: SnapshotMeta{
			Version:            version,
			ID:                 name,
			Index:              index,
			Term:               term,
			Peers:              encodePeers(configuration, trans),
			Configuration:      configuration,
			ConfigurationIndex: configurationIndex,
		},
		contents: &bytes.Buffer{},
	}
	m.hasSnapshot = true
	m.latest = sink

	return sink, nil
}
func ( m * InmemSnapshotStore ) Create ( version SnapshotVersion , index , term uint64 , configuration Configuration , configurationIndex uint64 , trans Transport ) ( SnapshotSink , error ) { // We only support version 1 snapshots at this time. if version != 1 { return nil , fmt . Errorf ( " " , version ) } name := snapshotName ( term , index ) m . Lock ( ) defer m . Unlock ( ) sink := & InmemSnapshotSink { meta : SnapshotMeta { Version : version , ID : name , Index : index , Term : term , Peers : encodePeers ( configuration , trans ) , Configuration : configuration , ConfigurationIndex : configurationIndex , } , contents : & bytes . Buffer { } , } m . hasSnapshot = true m . latest = sink return sink , nil }
// Create replaces the stored snapshot with a new one using the given args
Create replaces the stored snapshot with a new one using the given args