trpc.group/trpc-go/trpc-go@v1.0.3/naming/selector/passthrough.go (about) 1 // 2 // 3 // Tencent is pleased to support the open source community by making tRPC available. 4 // 5 // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 // All rights reserved. 7 // 8 // If you have downloaded a copy of the tRPC source code from Tencent, 9 // please note that tRPC source code is licensed under the Apache 2.0 License, 10 // A copy of the Apache 2.0 License is included in this file. 11 // 12 // 13 14 package selector 15 16 import ( 17 "time" 18 19 "trpc.group/trpc-go/trpc-go/naming/registry" 20 ) 21 22 func init() { 23 Register("passthrough", NewPassthroughSelector()) // passthrough://temp.sock 24 Register("unix", NewPassthroughSelector()) // unix://temp.sock 25 } 26 27 // passthroughSelector is a selector simply passthrough serviceName. 28 type passthroughSelector struct{} 29 30 // NewPassthroughSelector creates a new passthroughSelector. 31 func NewPassthroughSelector() *passthroughSelector { 32 return &passthroughSelector{} 33 } 34 35 // Select implements Selector.Select, passthrough service name. 36 func (s *passthroughSelector) Select( 37 serviceName string, opt ...Option, 38 ) (*registry.Node, error) { 39 return ®istry.Node{ 40 ServiceName: serviceName, 41 Address: serviceName, 42 }, nil 43 } 44 45 // Report reports nothing. 46 func (s *passthroughSelector) Report(*registry.Node, time.Duration, error) error { 47 return nil 48 }