mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-10-31 16:32:12 +08:00 
			
		
		
		
	* pb * fix: Modifying other fields while setting IsPrivateChat does not take effect * fix: quote message error revoke * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * rpc client * rpc client * rpc client * rpc client * rpc client * rpc client * rpc client * rpc client
		
			
				
	
	
		
			33 lines
		
	
	
		
			639 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			639 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package rpcli
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"github.com/openimsdk/tools/errs"
 | |
| 	"google.golang.org/grpc"
 | |
| )
 | |
| 
 | |
| func extractField[A, B, C any](ctx context.Context, fn func(ctx context.Context, req *A, opts ...grpc.CallOption) (*B, error), req *A, get func(*B) C) (C, error) {
 | |
| 	resp, err := fn(ctx, req)
 | |
| 	if err != nil {
 | |
| 		var c C
 | |
| 		return c, err
 | |
| 	}
 | |
| 	return get(resp), nil
 | |
| }
 | |
| 
 | |
| func firstValue[A any](val []A, err error) (A, error) {
 | |
| 	if err != nil {
 | |
| 		var a A
 | |
| 		return a, err
 | |
| 	}
 | |
| 	if len(val) == 0 {
 | |
| 		var a A
 | |
| 		return a, errs.ErrRecordNotFound.WrapMsg("record not found")
 | |
| 	}
 | |
| 	return val[0], nil
 | |
| }
 | |
| 
 | |
| func ignoreResp(_ any, err error) error {
 | |
| 	return err
 | |
| }
 |