github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/trace/scheme_gtrace.go (about)

     1  // Code generated by gtrace. DO NOT EDIT.
     2  
     3  package trace
     4  
     5  import (
     6  	"context"
     7  )
     8  
     9  // schemeComposeOptions is a holder of options
    10  type schemeComposeOptions struct {
    11  	panicCallback func(e interface{})
    12  }
    13  
    14  // SchemeOption specified Scheme compose option
    15  type SchemeComposeOption func(o *schemeComposeOptions)
    16  
    17  // WithSchemePanicCallback specified behavior on panic
    18  func WithSchemePanicCallback(cb func(e interface{})) SchemeComposeOption {
    19  	return func(o *schemeComposeOptions) {
    20  		o.panicCallback = cb
    21  	}
    22  }
    23  
    24  // Compose returns a new Scheme which has functional fields composed both from t and x.
    25  func (t *Scheme) Compose(x *Scheme, opts ...SchemeComposeOption) *Scheme {
    26  	var ret Scheme
    27  	options := schemeComposeOptions{}
    28  	for _, opt := range opts {
    29  		if opt != nil {
    30  			opt(&options)
    31  		}
    32  	}
    33  	{
    34  		h1 := t.OnListDirectory
    35  		h2 := x.OnListDirectory
    36  		ret.OnListDirectory = func(s SchemeListDirectoryStartInfo) func(SchemeListDirectoryDoneInfo) {
    37  			if options.panicCallback != nil {
    38  				defer func() {
    39  					if e := recover(); e != nil {
    40  						options.panicCallback(e)
    41  					}
    42  				}()
    43  			}
    44  			var r, r1 func(SchemeListDirectoryDoneInfo)
    45  			if h1 != nil {
    46  				r = h1(s)
    47  			}
    48  			if h2 != nil {
    49  				r1 = h2(s)
    50  			}
    51  			return func(s SchemeListDirectoryDoneInfo) {
    52  				if options.panicCallback != nil {
    53  					defer func() {
    54  						if e := recover(); e != nil {
    55  							options.panicCallback(e)
    56  						}
    57  					}()
    58  				}
    59  				if r != nil {
    60  					r(s)
    61  				}
    62  				if r1 != nil {
    63  					r1(s)
    64  				}
    65  			}
    66  		}
    67  	}
    68  	{
    69  		h1 := t.OnDescribePath
    70  		h2 := x.OnDescribePath
    71  		ret.OnDescribePath = func(s SchemeDescribePathStartInfo) func(SchemeDescribePathDoneInfo) {
    72  			if options.panicCallback != nil {
    73  				defer func() {
    74  					if e := recover(); e != nil {
    75  						options.panicCallback(e)
    76  					}
    77  				}()
    78  			}
    79  			var r, r1 func(SchemeDescribePathDoneInfo)
    80  			if h1 != nil {
    81  				r = h1(s)
    82  			}
    83  			if h2 != nil {
    84  				r1 = h2(s)
    85  			}
    86  			return func(s SchemeDescribePathDoneInfo) {
    87  				if options.panicCallback != nil {
    88  					defer func() {
    89  						if e := recover(); e != nil {
    90  							options.panicCallback(e)
    91  						}
    92  					}()
    93  				}
    94  				if r != nil {
    95  					r(s)
    96  				}
    97  				if r1 != nil {
    98  					r1(s)
    99  				}
   100  			}
   101  		}
   102  	}
   103  	{
   104  		h1 := t.OnMakeDirectory
   105  		h2 := x.OnMakeDirectory
   106  		ret.OnMakeDirectory = func(s SchemeMakeDirectoryStartInfo) func(SchemeMakeDirectoryDoneInfo) {
   107  			if options.panicCallback != nil {
   108  				defer func() {
   109  					if e := recover(); e != nil {
   110  						options.panicCallback(e)
   111  					}
   112  				}()
   113  			}
   114  			var r, r1 func(SchemeMakeDirectoryDoneInfo)
   115  			if h1 != nil {
   116  				r = h1(s)
   117  			}
   118  			if h2 != nil {
   119  				r1 = h2(s)
   120  			}
   121  			return func(s SchemeMakeDirectoryDoneInfo) {
   122  				if options.panicCallback != nil {
   123  					defer func() {
   124  						if e := recover(); e != nil {
   125  							options.panicCallback(e)
   126  						}
   127  					}()
   128  				}
   129  				if r != nil {
   130  					r(s)
   131  				}
   132  				if r1 != nil {
   133  					r1(s)
   134  				}
   135  			}
   136  		}
   137  	}
   138  	{
   139  		h1 := t.OnRemoveDirectory
   140  		h2 := x.OnRemoveDirectory
   141  		ret.OnRemoveDirectory = func(s SchemeRemoveDirectoryStartInfo) func(SchemeRemoveDirectoryDoneInfo) {
   142  			if options.panicCallback != nil {
   143  				defer func() {
   144  					if e := recover(); e != nil {
   145  						options.panicCallback(e)
   146  					}
   147  				}()
   148  			}
   149  			var r, r1 func(SchemeRemoveDirectoryDoneInfo)
   150  			if h1 != nil {
   151  				r = h1(s)
   152  			}
   153  			if h2 != nil {
   154  				r1 = h2(s)
   155  			}
   156  			return func(s SchemeRemoveDirectoryDoneInfo) {
   157  				if options.panicCallback != nil {
   158  					defer func() {
   159  						if e := recover(); e != nil {
   160  							options.panicCallback(e)
   161  						}
   162  					}()
   163  				}
   164  				if r != nil {
   165  					r(s)
   166  				}
   167  				if r1 != nil {
   168  					r1(s)
   169  				}
   170  			}
   171  		}
   172  	}
   173  	{
   174  		h1 := t.OnModifyPermissions
   175  		h2 := x.OnModifyPermissions
   176  		ret.OnModifyPermissions = func(s SchemeModifyPermissionsStartInfo) func(SchemeModifyPermissionsDoneInfo) {
   177  			if options.panicCallback != nil {
   178  				defer func() {
   179  					if e := recover(); e != nil {
   180  						options.panicCallback(e)
   181  					}
   182  				}()
   183  			}
   184  			var r, r1 func(SchemeModifyPermissionsDoneInfo)
   185  			if h1 != nil {
   186  				r = h1(s)
   187  			}
   188  			if h2 != nil {
   189  				r1 = h2(s)
   190  			}
   191  			return func(s SchemeModifyPermissionsDoneInfo) {
   192  				if options.panicCallback != nil {
   193  					defer func() {
   194  						if e := recover(); e != nil {
   195  							options.panicCallback(e)
   196  						}
   197  					}()
   198  				}
   199  				if r != nil {
   200  					r(s)
   201  				}
   202  				if r1 != nil {
   203  					r1(s)
   204  				}
   205  			}
   206  		}
   207  	}
   208  	return &ret
   209  }
   210  func (t *Scheme) onListDirectory(s SchemeListDirectoryStartInfo) func(SchemeListDirectoryDoneInfo) {
   211  	fn := t.OnListDirectory
   212  	if fn == nil {
   213  		return func(SchemeListDirectoryDoneInfo) {
   214  			return
   215  		}
   216  	}
   217  	res := fn(s)
   218  	if res == nil {
   219  		return func(SchemeListDirectoryDoneInfo) {
   220  			return
   221  		}
   222  	}
   223  	return res
   224  }
   225  func (t *Scheme) onDescribePath(s SchemeDescribePathStartInfo) func(SchemeDescribePathDoneInfo) {
   226  	fn := t.OnDescribePath
   227  	if fn == nil {
   228  		return func(SchemeDescribePathDoneInfo) {
   229  			return
   230  		}
   231  	}
   232  	res := fn(s)
   233  	if res == nil {
   234  		return func(SchemeDescribePathDoneInfo) {
   235  			return
   236  		}
   237  	}
   238  	return res
   239  }
   240  func (t *Scheme) onMakeDirectory(s SchemeMakeDirectoryStartInfo) func(SchemeMakeDirectoryDoneInfo) {
   241  	fn := t.OnMakeDirectory
   242  	if fn == nil {
   243  		return func(SchemeMakeDirectoryDoneInfo) {
   244  			return
   245  		}
   246  	}
   247  	res := fn(s)
   248  	if res == nil {
   249  		return func(SchemeMakeDirectoryDoneInfo) {
   250  			return
   251  		}
   252  	}
   253  	return res
   254  }
   255  func (t *Scheme) onRemoveDirectory(s SchemeRemoveDirectoryStartInfo) func(SchemeRemoveDirectoryDoneInfo) {
   256  	fn := t.OnRemoveDirectory
   257  	if fn == nil {
   258  		return func(SchemeRemoveDirectoryDoneInfo) {
   259  			return
   260  		}
   261  	}
   262  	res := fn(s)
   263  	if res == nil {
   264  		return func(SchemeRemoveDirectoryDoneInfo) {
   265  			return
   266  		}
   267  	}
   268  	return res
   269  }
   270  func (t *Scheme) onModifyPermissions(s SchemeModifyPermissionsStartInfo) func(SchemeModifyPermissionsDoneInfo) {
   271  	fn := t.OnModifyPermissions
   272  	if fn == nil {
   273  		return func(SchemeModifyPermissionsDoneInfo) {
   274  			return
   275  		}
   276  	}
   277  	res := fn(s)
   278  	if res == nil {
   279  		return func(SchemeModifyPermissionsDoneInfo) {
   280  			return
   281  		}
   282  	}
   283  	return res
   284  }
   285  func SchemeOnListDirectory(t *Scheme, c *context.Context, call call) func(error) {
   286  	var p SchemeListDirectoryStartInfo
   287  	p.Context = c
   288  	p.Call = call
   289  	res := t.onListDirectory(p)
   290  	return func(e error) {
   291  		var p SchemeListDirectoryDoneInfo
   292  		p.Error = e
   293  		res(p)
   294  	}
   295  }
   296  func SchemeOnDescribePath(t *Scheme, c *context.Context, call call, path string) func(entryType string, _ error) {
   297  	var p SchemeDescribePathStartInfo
   298  	p.Context = c
   299  	p.Call = call
   300  	p.Path = path
   301  	res := t.onDescribePath(p)
   302  	return func(entryType string, e error) {
   303  		var p SchemeDescribePathDoneInfo
   304  		p.EntryType = entryType
   305  		p.Error = e
   306  		res(p)
   307  	}
   308  }
   309  func SchemeOnMakeDirectory(t *Scheme, c *context.Context, call call, path string) func(error) {
   310  	var p SchemeMakeDirectoryStartInfo
   311  	p.Context = c
   312  	p.Call = call
   313  	p.Path = path
   314  	res := t.onMakeDirectory(p)
   315  	return func(e error) {
   316  		var p SchemeMakeDirectoryDoneInfo
   317  		p.Error = e
   318  		res(p)
   319  	}
   320  }
   321  func SchemeOnRemoveDirectory(t *Scheme, c *context.Context, call call, path string) func(error) {
   322  	var p SchemeRemoveDirectoryStartInfo
   323  	p.Context = c
   324  	p.Call = call
   325  	p.Path = path
   326  	res := t.onRemoveDirectory(p)
   327  	return func(e error) {
   328  		var p SchemeRemoveDirectoryDoneInfo
   329  		p.Error = e
   330  		res(p)
   331  	}
   332  }
   333  func SchemeOnModifyPermissions(t *Scheme, c *context.Context, call call, path string) func(error) {
   334  	var p SchemeModifyPermissionsStartInfo
   335  	p.Context = c
   336  	p.Call = call
   337  	p.Path = path
   338  	res := t.onModifyPermissions(p)
   339  	return func(e error) {
   340  		var p SchemeModifyPermissionsDoneInfo
   341  		p.Error = e
   342  		res(p)
   343  	}
   344  }