github.com/ronaksoft/rony@v0.16.26-0.20230807065236-1743dbfe6959/internal/msg/imsg.rony.go (about)

     1  // Code generated by Rony's protoc plugin; DO NOT EDIT.
     2  // ProtoC ver. v3.17.3
     3  // Rony ver. v0.16.24
     4  // Source: imsg.proto
     5  
     6  package msg
     7  
     8  import (
     9  	bytes "bytes"
    10  	sync "sync"
    11  
    12  	rony "github.com/ronaksoft/rony"
    13  	pools "github.com/ronaksoft/rony/pools"
    14  	registry "github.com/ronaksoft/rony/registry"
    15  	protojson "google.golang.org/protobuf/encoding/protojson"
    16  	proto "google.golang.org/protobuf/proto"
    17  )
    18  
    19  var _ = pools.Imported
    20  
    21  const C_TunnelMessage uint64 = 12904103981552626014
    22  
    23  type poolTunnelMessage struct {
    24  	pool sync.Pool
    25  }
    26  
    27  func (p *poolTunnelMessage) Get() *TunnelMessage {
    28  	x, ok := p.pool.Get().(*TunnelMessage)
    29  	if !ok {
    30  		x = &TunnelMessage{}
    31  	}
    32  
    33  	x.Envelope = rony.PoolMessageEnvelope.Get()
    34  
    35  	return x
    36  }
    37  
    38  func (p *poolTunnelMessage) Put(x *TunnelMessage) {
    39  	if x == nil {
    40  		return
    41  	}
    42  
    43  	x.SenderID = x.SenderID[:0]
    44  	x.SenderReplicaSet = 0
    45  	for _, z := range x.Store {
    46  		rony.PoolKeyValue.Put(z)
    47  	}
    48  	x.Store = x.Store[:0]
    49  	rony.PoolMessageEnvelope.Put(x.Envelope)
    50  
    51  	p.pool.Put(x)
    52  }
    53  
    54  var PoolTunnelMessage = poolTunnelMessage{}
    55  
    56  func (x *TunnelMessage) DeepCopy(z *TunnelMessage) {
    57  	z.SenderID = append(z.SenderID[:0], x.SenderID...)
    58  	z.SenderReplicaSet = x.SenderReplicaSet
    59  	for idx := range x.Store {
    60  		if x.Store[idx] == nil {
    61  			continue
    62  		}
    63  		xx := rony.PoolKeyValue.Get()
    64  		x.Store[idx].DeepCopy(xx)
    65  		z.Store = append(z.Store, xx)
    66  	}
    67  	if x.Envelope != nil {
    68  		if z.Envelope == nil {
    69  			z.Envelope = rony.PoolMessageEnvelope.Get()
    70  		}
    71  		x.Envelope.DeepCopy(z.Envelope)
    72  	} else {
    73  		rony.PoolMessageEnvelope.Put(z.Envelope)
    74  		z.Envelope = nil
    75  	}
    76  }
    77  
    78  func (x *TunnelMessage) Clone() *TunnelMessage {
    79  	z := &TunnelMessage{}
    80  	x.DeepCopy(z)
    81  	return z
    82  }
    83  
    84  func (x *TunnelMessage) Unmarshal(b []byte) error {
    85  	return proto.UnmarshalOptions{Merge: true}.Unmarshal(b, x)
    86  }
    87  
    88  func (x *TunnelMessage) Marshal() ([]byte, error) {
    89  	return proto.Marshal(x)
    90  }
    91  
    92  func (x *TunnelMessage) UnmarshalJSON(b []byte) error {
    93  	return protojson.Unmarshal(b, x)
    94  }
    95  
    96  func (x *TunnelMessage) MarshalJSON() ([]byte, error) {
    97  	return protojson.Marshal(x)
    98  }
    99  
   100  func factoryTunnelMessage() registry.Message {
   101  	return &TunnelMessage{}
   102  }
   103  
   104  const C_EdgeNode uint64 = 12741646567456486228
   105  
   106  type poolEdgeNode struct {
   107  	pool sync.Pool
   108  }
   109  
   110  func (p *poolEdgeNode) Get() *EdgeNode {
   111  	x, ok := p.pool.Get().(*EdgeNode)
   112  	if !ok {
   113  		x = &EdgeNode{}
   114  	}
   115  
   116  	return x
   117  }
   118  
   119  func (p *poolEdgeNode) Put(x *EdgeNode) {
   120  	if x == nil {
   121  		return
   122  	}
   123  
   124  	x.ServerID = x.ServerID[:0]
   125  	x.ReplicaSet = 0
   126  	x.Hash = 0
   127  	x.GatewayAddr = x.GatewayAddr[:0]
   128  	x.TunnelAddr = x.TunnelAddr[:0]
   129  
   130  	p.pool.Put(x)
   131  }
   132  
   133  var PoolEdgeNode = poolEdgeNode{}
   134  
   135  func (x *EdgeNode) DeepCopy(z *EdgeNode) {
   136  	z.ServerID = append(z.ServerID[:0], x.ServerID...)
   137  	z.ReplicaSet = x.ReplicaSet
   138  	z.Hash = x.Hash
   139  	z.GatewayAddr = append(z.GatewayAddr[:0], x.GatewayAddr...)
   140  	z.TunnelAddr = append(z.TunnelAddr[:0], x.TunnelAddr...)
   141  }
   142  
   143  func (x *EdgeNode) Clone() *EdgeNode {
   144  	z := &EdgeNode{}
   145  	x.DeepCopy(z)
   146  	return z
   147  }
   148  
   149  func (x *EdgeNode) Unmarshal(b []byte) error {
   150  	return proto.UnmarshalOptions{Merge: true}.Unmarshal(b, x)
   151  }
   152  
   153  func (x *EdgeNode) Marshal() ([]byte, error) {
   154  	return proto.Marshal(x)
   155  }
   156  
   157  func (x *EdgeNode) UnmarshalJSON(b []byte) error {
   158  	return protojson.Unmarshal(b, x)
   159  }
   160  
   161  func (x *EdgeNode) MarshalJSON() ([]byte, error) {
   162  	return protojson.Marshal(x)
   163  }
   164  
   165  func factoryEdgeNode() registry.Message {
   166  	return &EdgeNode{}
   167  }
   168  
   169  // register constructors of the messages to the registry package
   170  func init() {
   171  	registry.Register(12904103981552626014, "TunnelMessage", factoryTunnelMessage)
   172  	registry.Register(12741646567456486228, "EdgeNode", factoryEdgeNode)
   173  
   174  }
   175  
   176  var _ = bytes.MinRead