mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-08-20 09:53:01 +08:00
Some checks are pending
go: build dev binaries / cleanup (push) Waiting to run
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Blocked by required conditions
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Blocked by required conditions
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Blocked by required conditions
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Blocked by required conditions
docker: build dev containers / build-dev-containers (push) Waiting to run
End to End / FUSE Mount (push) Waiting to run
go: build binary / Build (push) Waiting to run
Ceph S3 tests / Ceph S3 tests (push) Waiting to run
* rename * set agent address * refactor * add agent sub * pub messages * grpc new client * can publish records via agent * send init message with session id * fmt * check cancelled request while waiting * use sessionId * handle possible nil stream * subscriber process messages * separate debug port * use atomic int64 * less logs * minor * skip io.EOF * rename * remove unused * use saved offsets * do not reuse session, since always session id is new after restart remove last active ts from SessionEntry * simplify printing * purge unused * just proxy the subscription, skipping the session step * adjust offset types * subscribe offset type and possible value * start after the known tsns * avoid wrongly set startPosition * move * remove * refactor * typo * fix * fix changed path
45 lines
917 B
Go
45 lines
917 B
Go
package agent
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/mq_agent_pb"
|
|
)
|
|
|
|
func (a *MessageQueueAgent) PublishRecord(stream mq_agent_pb.SeaweedMessagingAgent_PublishRecordServer) error {
|
|
m, err := stream.Recv()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
sessionId := SessionId(m.SessionId)
|
|
a.publishersLock.RLock()
|
|
publisherEntry, found := a.publishers[sessionId]
|
|
a.publishersLock.RUnlock()
|
|
if !found {
|
|
return fmt.Errorf("publish session id %d not found", sessionId)
|
|
}
|
|
defer func() {
|
|
a.publishersLock.Lock()
|
|
delete(a.publishers, sessionId)
|
|
a.publishersLock.Unlock()
|
|
}()
|
|
|
|
if m.Value != nil {
|
|
if err := publisherEntry.entry.PublishRecord(m.Key, m.Value); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
for {
|
|
m, err = stream.Recv()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if m.Value == nil {
|
|
continue
|
|
}
|
|
if err := publisherEntry.entry.PublishRecord(m.Key, m.Value); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|