github.com/cloudwego/kitex@v0.9.0/pkg/rpcinfo/mutable.go (about)

     1  /*
     2   * Copyright 2021 CloudWeGo Authors
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  package rpcinfo
    18  
    19  import (
    20  	"net"
    21  	"time"
    22  
    23  	"github.com/cloudwego/kitex/pkg/serviceinfo"
    24  	"github.com/cloudwego/kitex/pkg/stats"
    25  	"github.com/cloudwego/kitex/transport"
    26  )
    27  
    28  // MutableEndpointInfo is used to change the information in the EndpointInfo.
    29  type MutableEndpointInfo interface {
    30  	SetServiceName(service string) error
    31  	SetMethod(method string) error
    32  	SetAddress(addr net.Addr) error
    33  	SetTag(key, value string) error
    34  	ImmutableView() EndpointInfo
    35  	Reset()
    36  	ResetFromBasicInfo(bi *EndpointBasicInfo)
    37  }
    38  
    39  // MutableRPCConfig is used to change the information in the RPCConfig.
    40  type MutableRPCConfig interface {
    41  	SetRPCTimeout(to time.Duration) error
    42  	IsRPCTimeoutLocked() bool
    43  	SetConnectTimeout(to time.Duration) error
    44  	IsConnectTimeoutLocked() bool
    45  	SetReadWriteTimeout(to time.Duration) error
    46  	IsReadWriteTimeoutLocked() bool
    47  	SetIOBufferSize(sz int) error
    48  	SetTransportProtocol(tp transport.Protocol) error
    49  	SetInteractionMode(mode InteractionMode) error
    50  	LockConfig(bits int)
    51  	Clone() MutableRPCConfig
    52  	CopyFrom(from RPCConfig)
    53  	ImmutableView() RPCConfig
    54  	SetPayloadCodec(codec serviceinfo.PayloadCodec)
    55  }
    56  
    57  // MutableRPCStats is used to change the information in the RPCStats.
    58  type MutableRPCStats interface {
    59  	SetSendSize(size uint64)
    60  	SetRecvSize(size uint64)
    61  	SetError(err error)
    62  	SetPanicked(x interface{})
    63  	SetLevel(level stats.Level)
    64  	Reset()
    65  	ImmutableView() RPCStats
    66  	IncrSendSize(size uint64)
    67  	IncrRecvSize(size uint64)
    68  }