// ProcessExtension calles the handler for a specified extension.
422086
func ProcessExtension(handleExtension extensionHandler) {
	response := &ExtensionHandlerResponse{}
	forInputYamlFromOpenapic(
		func(version string, extensionName string, yamlInput string) {
			var newObject proto.Message
			var err error

			handled, newObject, err := handleExtension(extensionName, yamlInput)
			if !handled {
				responseBytes, _ := proto.Marshal(response)
				os.Stdout.Write(responseBytes)
				os.Exit(0)
			}

			// If we reach here, then the extension is handled
			response.Handled = true
			if err != nil {
				response.Error = append(response.Error, err.Error())
				responseBytes, _ := proto.Marshal(response)
				os.Stdout.Write(responseBytes)
				os.Exit(0)
			}
			response.Value, err = ptypes.MarshalAny(newObject)
			if err != nil {
				response.Error = append(response.Error, err.Error())
				responseBytes, _ := proto.Marshal(response)
				os.Stdout.Write(responseBytes)
				os.Exit(0)
			}
		})

	responseBytes, _ := proto.Marshal(response)
	os.Stdout.Write(responseBytes)
}
5854
func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, deterministic bool) ([]byte, error) {
	m, mu := ext.extensionsRead()
	if m == nil {
		return b, nil
	}
	mu.Lock()
	defer mu.Unlock()

	var err error
	var nerr nonFatal

	// Fast-path for common cases: zero or one extensions.
	// Don't bother sorting the keys.
	if len(m) <= 1 {
		for _, e := range m {
			if e.value == nil || e.desc == nil {
				// Extension is only in its encoded form.
				b = append(b, e.enc...)
				continue
			}

			// We don't skip extensions that have an encoded form set,
			// because the extension value may have been mutated after
			// the last time this function was called.

			ei := u.getExtElemInfo(e.desc)
			v := e.value
			p := toAddrPointer(&v, ei.isptr, ei.deref)
			b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
			if !nerr.Merge(err) {
				return b, err
			}
		}
		return b, nerr.E
	}

	// Sort the keys to provide a deterministic encoding.
	// Not sure this is required, but the old code does it.
	keys := make([]int, 0, len(m))
	for k := range m {
		keys = append(keys, int(k))
	}
	sort.Ints(keys)

	for _, k := range keys {
		e := m[int32(k)]
		if e.value == nil || e.desc == nil {
			// Extension is only in its encoded form.
			b = append(b, e.enc...)
			continue
		}

		// We don't skip extensions that have an encoded form set,
		// because the extension value may have been mutated after
		// the last time this function was called.

		ei := u.getExtElemInfo(e.desc)
		v := e.value
		p := toAddrPointer(&v, ei.isptr, ei.deref)
		b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
		if !nerr.Merge(err) {
			return b, err
		}
	}
	return b, nerr.E
}
307346
func (c *Capabilities) addExtension(r io.Reader) error {
	var buf bytes.Buffer
	encoder := base64.NewEncoder(base64.StdEncoding, &buf)
	if _, err := io.Copy(encoder, bufio.NewReader(r)); err != nil {
		return err
	}
	encoder.Close()
	c.Extensions = append(c.Extensions, buf.String())
	return nil
}
1169264
func SplitExtension(name string) (
	assertions, extensionSuffix string, err error) {
	names := strings.SplitN(name, HandleExtensionSep, 2)
	if len(names) > 2 {
		return "", "", BadNameError{name}
	}
	if len(names) > 1 {
		extensionSuffix = names[1]
	}
	return names[0], extensionSuffix, nil
}
1047902
func (handler *handler) Handle(_ <-chan struct{}, applications []string) error {
	return handler.config.Facade.Rescale(applications)
}
1331564
func (b *Backend) ProcessEvents(ev ...*auditinternal.Event) bool {
	if b.OnRequest != nil {
		b.OnRequest(ev)
	}
	return true
}
122169
func (s *Output) SetExtension(v string) *Output {
	s.Extension = &v
	return s
}
1012910
func NewExtensions(c *Config) (*ExtensionsClient, error) {
	config := *c
	if err := setExtensionsDefaults(&config); err != nil {
		return nil, err
	}
	client, err := RESTClientFor(&config)
	if err != nil {
		return nil, err
	}
	return &ExtensionsClient{client}, nil
}
862177
func newExtensionHandler(params []byte, pers protocol.Perspective) tlsExtensionHandler {
	return &extensionHandler{
		ourParams:   params,
		paramsChan:  make(chan []byte),
		perspective: pers,
	}
}
43529
func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) {
	epb, err := extendable(pb)
	if err != nil {
		return nil, err
	}
	extensions = make([]interface{}, len(es))
	for i, e := range es {
		extensions[i], err = GetExtension(epb, e)
		if err == ErrMissingExtension {
			err = nil
		}
		if err != nil {
			return
		}
	}
	return
}
917916
func newExtendedResourceToleration() *plugin {
	return &plugin{
		Handler: admission.NewHandler(admission.Create, admission.Update),
	}
}
976416
func (c *Client) Process(res resource.Resource, options Options) (resource.Resource, error) {
	return c.rs.Transform(
		res,
		&postcssTransformation{rs: c.rs, options: options},
	)
}
1087798
func handleExtensionsValidationDidStart(p *Params) ([]gqlerrors.FormattedError, validationFinishFuncHandler) {
	fs := map[string]ValidationFinishFunc{}
	errs := gqlerrors.FormattedErrors{}
	for _, ext := range p.Schema.extensions {
		var (
			ctx      context.Context
			finishFn ValidationFinishFunc
		)
		// catch panic from an extension's validationDidStart function
		func() {
			defer func() {
				if r := recover(); r != nil {
					errs = append(errs, gqlerrors.FormatError(fmt.Errorf("%s.ValidationDidStart: %v", ext.Name(), r.(error))))
				}
			}()
			ctx, finishFn = ext.ValidationDidStart(p.Context)
			// update context
			p.Context = ctx
			fs[ext.Name()] = finishFn
		}()
	}
	return errs, func(errs []gqlerrors.FormattedError) []gqlerrors.FormattedError {
		extErrs := gqlerrors.FormattedErrors{}
		for name, finishFn := range fs {
			func() {
				// catch panic from a finishFn
				defer func() {
					if r := recover(); r != nil {
						extErrs = append(extErrs, gqlerrors.FormatError(fmt.Errorf("%s.ValidationFinishFunc: %v", name, r.(error))))
					}
				}()
				finishFn(errs)
			}()
		}
		return extErrs
	}
}
147611
func newHandleExtensionSuffix(
	extensions []HandleExtension, isBackedByTeam bool) string {
	var suffix string
	for _, extension := range extensions {
		suffix += HandleExtensionSep
		suffix += extension.string(isBackedByTeam)
	}
	return suffix
}
129758
func Compresses(exts []string) HandlerFunc {
	extsmap := make(map[string]bool)
	for _, ext := range exts {
		extsmap[strings.ToLower(ext)] = true
	}

	return func(ctx *Context) {
		ae := ctx.Req().Header.Get("Accept-Encoding")
		if ae == "" {
			ctx.Next()
			return
		}

		if len(extsmap) > 0 {
			ext := strings.ToLower(path.Ext(ctx.Req().URL.Path))
			if _, ok := extsmap[ext]; ok {
				compress(ctx, "auto")
				return
			}
		}

		if action := ctx.Action(); action != nil {
			if c, ok := action.(Compresser); ok {
				compress(ctx, c.CompressType())
				return
			}
		}

		// if blank, then no compress
		ctx.Next()
	}
}
571208
func (u *marshalInfo) sizeExtensions(ext *XXX_InternalExtensions) int {
	m, mu := ext.extensionsRead()
	if m == nil {
		return 0
	}
	mu.Lock()

	n := 0
	for _, e := range m {
		if e.value == nil || e.desc == nil {
			// Extension is only in its encoded form.
			n += len(e.enc)
			continue
		}

		// We don't skip extensions that have an encoded form set,
		// because the extension value may have been mutated after
		// the last time this function was called.
		ei := u.getExtElemInfo(e.desc)
		v := e.value
		p := toAddrPointer(&v, ei.isptr, ei.deref)
		n += ei.sizer(p, ei.tagsize)
	}
	mu.Unlock()
	return n
}
809994
func (b *BloomTrieIndexerBackend) Process(ctx context.Context, header *types.Header) error {
	num := header.Number.Uint64() - b.section*b.size
	if (num+1)%b.parentSize == 0 {
		b.sectionHeads[num/b.parentSize] = header.Hash()
	}
	return nil
}