github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/archive/proxy.go (about) 1 // Copyright (C) 2021-2022 Talos, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package archive 16 17 import ( 18 "fmt" 19 "time" 20 21 "github.com/lirm/aeron-go/aeron" 22 "github.com/lirm/aeron-go/aeron/atomic" 23 "github.com/lirm/aeron-go/aeron/logbuffer/term" 24 "github.com/lirm/aeron-go/archive/codecs" 25 ) 26 27 // Proxy class for encapsulating encoding and sending of control protocol messages to an archive 28 type Proxy struct { 29 Publication *aeron.Publication 30 archive *Archive // link to parent 31 marshaller *codecs.SbeGoMarshaller // currently shared as we're not reentrant (but could be here) 32 } 33 34 // Offer to our request publication with a retry to allow time for the image establishment, some back pressure etc 35 func (proxy *Proxy) Offer(buffer *atomic.Buffer, offset int32, length int32, reservedValueSupplier term.ReservedValueSupplier) int64 { 36 start := time.Now() 37 var ret int64 38 for time.Since(start) < proxy.archive.Options.Timeout { 39 ret = proxy.Publication.Offer(buffer, offset, length, reservedValueSupplier) 40 switch ret { 41 // Retry on these 42 case aeron.NotConnected, aeron.BackPressured, aeron.AdminAction: 43 proxy.archive.Options.IdleStrategy.Idle(0) 44 45 // Fail or succeed on other values 46 default: 47 return ret 48 } 49 } 50 51 // Give up, returning the last failure 52 logger.Debugf("Proxy.Offer timing out [%d]", ret) 53 return ret 54 55 } 56 57 // From here we have all the functions that create a data packet and send it on the 58 // publication. Responses will be processed on the control 59 60 // ConnectRequest packet and offer 61 func (proxy *Proxy) ConnectRequest(correlationID int64, responseStream int32, responseChannel string) error { 62 63 // Create a packet and send it 64 bytes, err := codecs.ConnectRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, correlationID, responseStream, responseChannel) 65 if err != nil { 66 return err 67 } 68 69 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 70 return fmt.Errorf("Offer failed: %d", ret) 71 } 72 73 return nil 74 } 75 76 // CloseSessionRequest packet and offer 77 func (proxy *Proxy) CloseSessionRequest() error { 78 // Create a packet and send it 79 bytes, err := codecs.CloseSessionRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID) 80 if err != nil { 81 return err 82 } 83 84 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 85 return fmt.Errorf("Offer failed: %d", ret) 86 } 87 88 return nil 89 } 90 91 // StartRecordingRequest packet and offer 92 // Uses the more recent protocol addition StartdRecordingRequest2 which added autoStop 93 func (proxy *Proxy) StartRecordingRequest(correlationID int64, stream int32, isLocal bool, autoStop bool, channel string) error { 94 95 bytes, err := codecs.StartRecordingRequest2Packet(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, stream, isLocal, autoStop, channel) 96 if err != nil { 97 return err 98 } 99 100 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 101 return fmt.Errorf("Offer failed: %d", ret) 102 } 103 104 return nil 105 } 106 107 // StopRecordingRequest packet and offer 108 func (proxy *Proxy) StopRecordingRequest(correlationID int64, stream int32, channel string) error { 109 // Create a packet and send it 110 bytes, err := codecs.StopRecordingRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, stream, channel) 111 if err != nil { 112 return err 113 } 114 115 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 116 return fmt.Errorf("Offer failed: %d", ret) 117 } 118 119 return nil 120 } 121 122 // ReplayRequest packet and offer 123 func (proxy *Proxy) ReplayRequest(correlationID int64, recordingID int64, position int64, length int64, replayChannel string, replayStream int32) error { 124 125 // Create a packet and send it 126 bytes, err := codecs.ReplayRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, recordingID, position, length, replayStream, replayChannel) 127 if err != nil { 128 return err 129 } 130 131 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 132 return fmt.Errorf("Offer failed: %d", ret) 133 } 134 135 return nil 136 } 137 138 // StopReplayRequest packet and offer 139 func (proxy *Proxy) StopReplayRequest(correlationID int64, replaySessionID int64) error { 140 // Create a packet and send it 141 bytes, err := codecs.StopReplayRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, replaySessionID) 142 if err != nil { 143 return err 144 } 145 146 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 147 return fmt.Errorf("Offer failed: %d", ret) 148 } 149 150 return nil 151 } 152 153 // ListRecordingsRequest packet and offer 154 // Lists up to recordCount recordings starting at fromRecordingID 155 func (proxy *Proxy) ListRecordingsRequest(correlationID int64, fromRecordingID int64, recordCount int32) error { 156 // Create a packet and send it 157 bytes, err := codecs.ListRecordingsRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, fromRecordingID, recordCount) 158 if err != nil { 159 return err 160 } 161 162 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 163 return fmt.Errorf("Offer failed: %d", ret) 164 } 165 166 return nil 167 } 168 169 // ListRecordingsForUriRequest packet and offer 170 // Lists up to recordCount recordings that match the channel and stream 171 func (proxy *Proxy) ListRecordingsForUriRequest(correlationID int64, fromRecordingID int64, recordCount int32, stream int32, channel string) error { 172 173 bytes, err := codecs.ListRecordingsForUriRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, fromRecordingID, recordCount, stream, channel) 174 175 if err != nil { 176 return err 177 } 178 179 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 180 return fmt.Errorf("Offer failed: %d", ret) 181 } 182 183 return nil 184 } 185 186 // ListRecordingRequest packet and offer 187 // Retrieves a recording descriptor for a specific recordingID 188 func (proxy *Proxy) ListRecordingRequest(correlationID int64, fromRecordingID int64) error { 189 // Create a packet and send it 190 bytes, err := codecs.ListRecordingRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, fromRecordingID) 191 if err != nil { 192 return err 193 } 194 195 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 196 return fmt.Errorf("Offer failed: %d", ret) 197 } 198 199 return nil 200 } 201 202 // ExtendRecordingRequest packet and offer 203 // Uses the more recent protocol addition ExtendRecordingRequest2 which added autoStop 204 func (proxy *Proxy) ExtendRecordingRequest(correlationID int64, recordingID int64, stream int32, sourceLocation codecs.SourceLocationEnum, autoStop bool, channel string) error { 205 // Create a packet and send it 206 bytes, err := codecs.ExtendRecordingRequest2Packet(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, recordingID, stream, sourceLocation, autoStop, channel) 207 if err != nil { 208 return err 209 } 210 211 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 212 return fmt.Errorf("Offer failed: %d", ret) 213 } 214 215 return nil 216 } 217 218 // RecordingPositionRequest packet and offer 219 func (proxy *Proxy) RecordingPositionRequest(correlationID int64, recordingID int64) error { 220 // Create a packet and send it 221 bytes, err := codecs.RecordingPositionRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, recordingID) 222 if err != nil { 223 return err 224 } 225 226 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 227 return fmt.Errorf("Offer failed: %d", ret) 228 } 229 230 return nil 231 } 232 233 // TruncateRecordingRequest packet and offer 234 func (proxy *Proxy) TruncateRecordingRequest(correlationID int64, recordingID int64, position int64) error { 235 // Create a packet and send it 236 bytes, err := codecs.TruncateRecordingRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, recordingID, position) 237 if err != nil { 238 return err 239 } 240 241 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 242 return fmt.Errorf("Offer failed: %d", ret) 243 } 244 245 return nil 246 } 247 248 // StopRecordingSubscriptionRequest packet and offer 249 func (proxy *Proxy) StopRecordingSubscriptionRequest(correlationID int64, subscriptionID int64) error { 250 // Create a packet and send it 251 bytes, err := codecs.StopRecordingSubscriptionPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, subscriptionID) 252 if err != nil { 253 return err 254 } 255 256 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 257 return fmt.Errorf("Offer failed: %d", ret) 258 } 259 260 return nil 261 } 262 263 // StopRecordingByIdentityRequest packet and offer 264 func (proxy *Proxy) StopRecordingByIdentityRequest(correlationID int64, recordingID int64) error { 265 // Create a packet and send it 266 bytes, err := codecs.StopRecordingByIdentityPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, recordingID) 267 if err != nil { 268 return err 269 } 270 271 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 272 return fmt.Errorf("Offer failed: %d", ret) 273 } 274 275 return nil 276 } 277 278 // StopPositionRequest packet and offer 279 func (proxy *Proxy) StopPositionRequest(correlationID int64, recordingID int64) error { 280 // Create a packet and send it 281 bytes, err := codecs.StopPositionPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, recordingID) 282 if err != nil { 283 return err 284 } 285 286 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 287 return fmt.Errorf("Offer failed: %d", ret) 288 } 289 290 return nil 291 } 292 293 // FindLastMatchingRecordingRequest packet and offer 294 func (proxy *Proxy) FindLastMatchingRecordingRequest(correlationID int64, minRecordingID int64, sessionID int32, stream int32, channel string) error { 295 296 // Create a packet and send it 297 bytes, err := codecs.FindLastMatchingRecordingPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, minRecordingID, sessionID, stream, channel) 298 if err != nil { 299 return err 300 } 301 302 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 303 return fmt.Errorf("Offer failed: %d", ret) 304 } 305 306 return nil 307 } 308 309 // ListRecordingSubscriptionsRequest packet and offer 310 func (proxy *Proxy) ListRecordingSubscriptionsRequest(correlationID int64, pseudoIndex int32, subscriptionCount int32, applyStreamID bool, stream int32, channel string) error { 311 312 // Create a packet and send it 313 bytes, err := codecs.ListRecordingSubscriptionsPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, pseudoIndex, subscriptionCount, applyStreamID, stream, channel) 314 if err != nil { 315 return err 316 } 317 318 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 319 return fmt.Errorf("Offer failed: %d", ret) 320 } 321 322 return nil 323 } 324 325 // BoundedReplayRequest packet and offer 326 func (proxy *Proxy) BoundedReplayRequest(correlationID int64, recordingID int64, position int64, length int64, limitCounterID int32, replayStream int32, replayChannel string) error { 327 328 // Create a packet and send it 329 bytes, err := codecs.BoundedReplayPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, recordingID, position, length, limitCounterID, replayStream, replayChannel) 330 if err != nil { 331 return err 332 } 333 334 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 335 return fmt.Errorf("Offer failed: %d", ret) 336 } 337 338 return nil 339 } 340 341 // StopAllReplaysRequest packet and offer 342 func (proxy *Proxy) StopAllReplaysRequest(correlationID int64, recordingID int64) error { 343 344 // Create a packet and send it 345 bytes, err := codecs.StopAllReplaysPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, recordingID) 346 if err != nil { 347 return err 348 } 349 350 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 351 return fmt.Errorf("Offer failed: %d", ret) 352 } 353 354 return nil 355 } 356 357 // CatalogHeaderRequest packet and offer 358 func (proxy *Proxy) CatalogHeaderRequest(version int32, length int32, nextRecordingID int64, alignment int32) error { 359 360 // Create a packet and send it 361 bytes, err := codecs.CatalogHeaderPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, version, length, nextRecordingID, alignment) 362 if err != nil { 363 return err 364 } 365 366 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 367 return fmt.Errorf("Offer failed: %d", ret) 368 } 369 370 return nil 371 } 372 373 // ReplicateRequest packet and offer 374 func (proxy *Proxy) ReplicateRequest(correlationID int64, srcRecordingID int64, dstRecordingID int64, srcControlStreamID int32, srcControlChannel string, liveDestination string) error { 375 // Create a packet and send it 376 bytes, err := codecs.ReplicateRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, srcRecordingID, dstRecordingID, srcControlStreamID, srcControlChannel, liveDestination) 377 if err != nil { 378 return err 379 } 380 381 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 382 return fmt.Errorf("Offer failed: %d", ret) 383 } 384 385 return nil 386 } 387 388 // ReplicateRequest2 packet and offer 389 func (proxy *Proxy) ReplicateRequest2(correlationID int64, srcRecordingID int64, dstRecordingID int64, stopPosition int64, channelTagID int64, srcControlStreamID int32, srcControlChannel string, liveDestination string, replicationChannel string) error { 390 // Create a packet and send it 391 bytes, err := codecs.ReplicateRequest2Packet(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, srcRecordingID, dstRecordingID, stopPosition, channelTagID, srcControlStreamID, srcControlChannel, liveDestination, replicationChannel) 392 if err != nil { 393 return err 394 } 395 396 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 397 return fmt.Errorf("Offer failed: %d", ret) 398 } 399 400 return nil 401 } 402 403 // StopReplicationRequest packet and offer 404 func (proxy *Proxy) StopReplicationRequest(correlationID int64, replicationID int64) error { 405 // Create a packet and send it 406 bytes, err := codecs.StopReplicationRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, replicationID) 407 if err != nil { 408 return err 409 } 410 411 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 412 return fmt.Errorf("Offer failed: %d", ret) 413 } 414 415 return nil 416 } 417 418 // StartPositionRequest packet and offer 419 func (proxy *Proxy) StartPositionRequest(correlationID int64, recordingID int64) error { 420 // Create a packet and send it 421 bytes, err := codecs.StartPositionRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, recordingID) 422 if err != nil { 423 return err 424 } 425 426 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 427 return fmt.Errorf("Offer failed: %d", ret) 428 } 429 430 return nil 431 } 432 433 // DetachSegmentsRequest packet and offer 434 func (proxy *Proxy) DetachSegmentsRequest(correlationID int64, recordingID int64, newStartPosition int64) error { 435 // Create a packet and send it 436 bytes, err := codecs.DetachSegmentsRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, recordingID, newStartPosition) 437 if err != nil { 438 return err 439 } 440 441 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 442 return fmt.Errorf("Offer failed: %d", ret) 443 } 444 445 return nil 446 } 447 448 // DeleteDetachedSegmentsRequest packet and offer 449 func (proxy *Proxy) DeleteDetachedSegmentsRequest(correlationID int64, recordingID int64) error { 450 // Create a packet and send it 451 bytes, err := codecs.DeleteDetachedSegmentsRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, recordingID) 452 if err != nil { 453 return err 454 } 455 456 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 457 return fmt.Errorf("Offer failed: %d", ret) 458 } 459 460 return nil 461 } 462 463 // PurgeSegmentsRequest packet and offer 464 func (proxy *Proxy) PurgeSegmentsRequest(correlationID int64, recordingID int64, newStartPosition int64) error { 465 // Create a packet and send it 466 bytes, err := codecs.PurgeSegmentsRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, recordingID, newStartPosition) 467 if err != nil { 468 return err 469 } 470 471 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 472 return fmt.Errorf("Offer failed: %d", ret) 473 } 474 475 return nil 476 } 477 478 // AttachSegmentsRequest packet and offer 479 func (proxy *Proxy) AttachSegmentsRequest(correlationID int64, recordingID int64) error { 480 // Create a packet and send it 481 bytes, err := codecs.AttachSegmentsRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, recordingID) 482 if err != nil { 483 return err 484 } 485 486 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 487 return fmt.Errorf("Offer failed: %d", ret) 488 } 489 490 return nil 491 } 492 493 // MigrateSegmentsRequest packet and offer 494 func (proxy *Proxy) MigrateSegmentsRequest(correlationID int64, srcRecordingID int64, destRecordingID int64) error { 495 // Create a packet and send it 496 bytes, err := codecs.MigrateSegmentsRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, srcRecordingID, destRecordingID) 497 if err != nil { 498 return err 499 } 500 501 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 502 return fmt.Errorf("Offer failed: %d", ret) 503 } 504 505 return nil 506 } 507 508 // AuthConnectRequest packet and offer 509 func (proxy *Proxy) AuthConnectRequest(correlationID int64, responseStream int32, responseChannel string, encodedCredentials []uint8) error { 510 511 // Create a packet and send it 512 bytes, err := codecs.AuthConnectRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, correlationID, responseStream, responseChannel, encodedCredentials) 513 if err != nil { 514 return err 515 } 516 517 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 518 return fmt.Errorf("Offer failed: %d", ret) 519 } 520 521 return nil 522 } 523 524 // ChallengeResponse packet and offer 525 func (proxy *Proxy) ChallengeResponse(correlationID int64, encodedCredentials []uint8) error { 526 // Create a packet and send it 527 bytes, err := codecs.ChallengeResponsePacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, encodedCredentials) 528 if err != nil { 529 return err 530 } 531 532 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 533 return fmt.Errorf("Offer failed: %d", ret) 534 } 535 536 return nil 537 } 538 539 // KeepAliveRequest packet and offer 540 func (proxy *Proxy) KeepAliveRequest(correlationID int64) error { 541 // Create a packet and send it 542 bytes, err := codecs.KeepAliveRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID) 543 if err != nil { 544 return err 545 } 546 547 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 548 return fmt.Errorf("Offer failed: %d", ret) 549 } 550 551 return nil 552 } 553 554 // TaggedReplicateRequest packet and offer 555 func (proxy *Proxy) TaggedReplicateRequest(correlationID int64, srcRecordingID int64, dstRecordingID int64, channelTagID int64, subscriptionTagID int64, srcControlStreamID int32, srcControlChannel string, liveDestination string) error { 556 // Create a packet and send it 557 bytes, err := codecs.TaggedReplicateRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, srcRecordingID, dstRecordingID, channelTagID, subscriptionTagID, srcControlStreamID, srcControlChannel, liveDestination) 558 if err != nil { 559 return err 560 } 561 562 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 563 return fmt.Errorf("Offer failed: %d", ret) 564 } 565 566 return nil 567 } 568 569 // PurgeRecordingRequest packet and offer 570 func (proxy *Proxy) PurgeRecordingRequest(correlationID int64, replaySessionID int64) error { 571 // Create a packet and send it 572 bytes, err := codecs.PurgeRecordingRequestPacket(proxy.marshaller, proxy.archive.Options.RangeChecking, proxy.archive.SessionID, correlationID, replaySessionID) 573 if err != nil { 574 return err 575 } 576 577 if ret := proxy.Offer(atomic.MakeBuffer(bytes, len(bytes)), 0, int32(len(bytes)), nil); ret < 0 { 578 return fmt.Errorf("Offer failed: %d", ret) 579 } 580 581 return nil 582 }