github.com/cloudwego/kitex@v0.9.0/client/streamclient/client_option_advanced.go (about) 1 /* 2 * Copyright 2023 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 streamclient 18 19 import ( 20 "context" 21 22 "github.com/cloudwego/kitex/client" 23 "github.com/cloudwego/kitex/pkg/acl" 24 "github.com/cloudwego/kitex/pkg/diagnosis" 25 "github.com/cloudwego/kitex/pkg/proxy" 26 "github.com/cloudwego/kitex/pkg/remote" 27 "github.com/cloudwego/kitex/pkg/rpcinfo" 28 ) 29 30 // These options are directly translated from client.Option(s). If you can't find the option with the 31 // same name in client.Option(s), most probably it means it's not for streaming clients. 32 33 // WithClientBasicInfo provides initial information for client endpoint in RPCInfo. 34 func WithClientBasicInfo(ebi *rpcinfo.EndpointBasicInfo) Option { 35 return ConvertOptionFrom(client.WithClientBasicInfo(ebi)) 36 } 37 38 // WithDiagnosisService sets the diagnosis service for gathering debug information. 39 func WithDiagnosisService(ds diagnosis.Service) Option { 40 return ConvertOptionFrom(client.WithDiagnosisService(ds)) 41 } 42 43 // WithACLRules adds ACL rules. 44 // Note that the ACL checking process happens before service discovery. 45 func WithACLRules(rules ...acl.RejectFunc) Option { 46 return ConvertOptionFrom(client.WithACLRules(rules...)) 47 } 48 49 // WithFirstMetaHandler adds a MetaHandler to the beginning of the current list. 50 func WithFirstMetaHandler(h remote.MetaHandler) Option { 51 return ConvertOptionFrom(client.WithFirstMetaHandler(h)) 52 } 53 54 // WithMetaHandler adds a MetaHandler to the end of the current list. 55 func WithMetaHandler(h remote.MetaHandler) Option { 56 return ConvertOptionFrom(client.WithMetaHandler(h)) 57 } 58 59 // WithProxy sets the forward Proxy for client. 60 func WithProxy(p proxy.ForwardProxy) Option { 61 return ConvertOptionFrom(client.WithProxy(p)) 62 } 63 64 // WithDialer sets the Dialer for creating connections. 65 func WithDialer(d remote.Dialer) Option { 66 return ConvertOptionFrom(client.WithDialer(d)) 67 } 68 69 // WithCloseCallbacks adds callback to Close 70 func WithCloseCallbacks(callback func() error) Option { 71 return ConvertOptionFrom(client.WithCloseCallbacks(callback)) 72 } 73 74 // WithErrorHandler sets the error handler. 75 func WithErrorHandler(f func(context.Context, error) error) Option { 76 return ConvertOptionFrom(client.WithErrorHandler(f)) 77 }