mirror of
https://github.com/nats-io/nats.go.git
synced 2025-10-05 16:48:43 +08:00
Started implementation of direct gets by subject
This commit is contained in:
3
js.go
3
js.go
@@ -169,6 +169,9 @@ const (
|
|||||||
// apiMsgGetT is the endpoint to perform a direct get of a message.
|
// apiMsgGetT is the endpoint to perform a direct get of a message.
|
||||||
apiDirectMsgGetT = "DIRECT.GET.%s"
|
apiDirectMsgGetT = "DIRECT.GET.%s"
|
||||||
|
|
||||||
|
// apiDirectMsgGetLastBySubjectT is the endpoint to perform a direct get of a message by subject.
|
||||||
|
apiDirectMsgGetLastBySubjectT = "DIRECT.GET.%s.%s"
|
||||||
|
|
||||||
// apiMsgDeleteT is the endpoint to remove a message.
|
// apiMsgDeleteT is the endpoint to remove a message.
|
||||||
apiMsgDeleteT = "STREAM.MSG.DELETE.%s"
|
apiMsgDeleteT = "STREAM.MSG.DELETE.%s"
|
||||||
|
|
||||||
|
14
jsm.go
14
jsm.go
@@ -887,6 +887,20 @@ func (js *js) getMsg(name string, mreq *apiMsgGetRequest, opts ...JSOpt) (*RawSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
var apiSubj string
|
var apiSubj string
|
||||||
|
|
||||||
|
doDirectGetLastBySubject := o.directGet && mreq.LastFor != ""
|
||||||
|
|
||||||
|
if doDirectGetLastBySubject && js.nc.serverMinVersion(2, 9, 0) {
|
||||||
|
apiSubj = apiDirectMsgGetLastBySubjectT
|
||||||
|
dsSubj := js.apiSubj(fmt.Sprintf(apiSubj, name, mreq.LastFor))
|
||||||
|
r, err := js.apiRequestWithContext(o.ctx, dsSubj, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return convertDirectGetMsgResponseToMsg(name, r)
|
||||||
|
}
|
||||||
|
|
||||||
if o.directGet {
|
if o.directGet {
|
||||||
apiSubj = apiDirectMsgGetT
|
apiSubj = apiDirectMsgGetT
|
||||||
mreq.NextFor = o.directNextFor
|
mreq.NextFor = o.directNextFor
|
||||||
|
Reference in New Issue
Block a user